diff --git a/..TODO/TODO.txt b/..TODO/TODO.txt index 4e2bdfd..e62b767 100644 --- a/..TODO/TODO.txt +++ b/..TODO/TODO.txt @@ -1,49 +1,71 @@ -TOP PRIORITY: -Add a shortcut to open tree tabs sidebar undo close to restore trees (will work ONLY in firefox) - - - -Loading data using message - Close tab on Middle mouse click and not On Middle mouse down - Split Pin size in theme +add groups scrolling arrows add textbox for ungrouped name in options - - - - - -LOW PRIORITY: - option for scrollbar on the left -folders - unread state? -menu: collapse entire tree -menu: expand tree menu: copy urls of the selected tabs menu: bookmark selected tabs/tree menu: select all menu: invert selection menu: close above/close below - -options: Customising the context menu +menu: Customising the context menu +menu: move to group +menu: Unload other click on active to return to previous tab - sort tabs/tree - maybe filter tabs on search +make tabs border width configurable, including size 0 +make tab spacing configurable, including 0 size -make tabs border width configurable, including size 0 +font size +hibernate group -make tab spacing confiogurable, including 0 size \ No newline at end of file +double click on tab actions selection like double click to be able to expand child tab. + I want you to be able to display the tab number count on the right end +customizable menu + +import session to unload tabs immediately +bind groups to FF containers + +Unread Tabs Color/Style +Give back group color (like it was before) + + +- When a pinned tab refreshes, it constantly blinks red. Suggest changing that to match Firefox's solid little blue indicator. It's less eye-catching (annoying) and more consistent. + +folders collapsed by default or make this optional + + +when actived tab located in folder, all tabs operation related with creating new tab (such as clone of tab in folder, new tab) must work only in current folder. + +New tab in selected folder! + + +separate option for close folder (close or promote children) +menu: unload tabs in folders + +menu: unload tabs must close real FF tabs, but your tabs must markeds like unloads and stay in list. + +Also all your tabs you can save in special folder of FF bookmarks and working from this place, where subdirs first level = groups for tab in left... Option for set base bookmark dir for addon can add to addon config. + +Whilst themes are apparently available, i couldn't just grab one via a drop-down which would make it easier. +Accept BCH (BitcoinCash) donations as the FEES make it FAR more palatable to donate (a few cents vs a few dollars). I bet you're missing out on plenty of micro donations because Bitcoin fees are so high it's no longer micro, and ETH is too high too (though not as bad). + +- I also support the suggestion of integrating Tree Tabs with Firefox sync. I definitely would have a great use for this possibility. +- Like many other commenters suggested, it would be wonderful to see some indication of the container a tab was opened in, if any. Getting an option to directly be able to chose to open a new tab in a container would also be very useful. + + +I don't understand those from comments +- add possibility open all tabs in folder in new left tab group with deleting this folder; +- for economy memory your tabs must to makings (html code) during activating left tab group or during unfold folders/trees; +- real FF tabs must creating and linking only after activate your tabs; \ No newline at end of file diff --git a/..Themes/Light and blue (by Guibuu).tt_theme b/..Themes/Light and blue (by Guibuu).tt_theme new file mode 100644 index 0000000..47d2b07 --- /dev/null +++ b/..Themes/Light and blue (by Guibuu).tt_theme @@ -0,0 +1 @@ +{"ToolbarShow":false,"ColorsSet":{"tab_border":"#fafafa","tab_hover_border":"#d7d7d7","tab_discarded_hover_border":"#d7d7d7","tab_discarded_border":"#fafafa","tabs_menu_hover_border":"#d7d7d7","tabs_menu_hover_background":"#d7d7d7","close_hover_border":"#939394","tab_selected_border":"#70c0e7","tab_selected_hover_border":"#70c0e7","tab_active_border":"#70c0e7","tab_discarded_background":"#fafafa","tab_background":"#fafafa","tab_discarded_title_font_color":"#353535","tab_discarded_hover_title_font_color":"#353535","tab_selected_discarded_title_font_color":"#353535","tab_selected_discarded_hover_title_font_color":"#353535","tab_title_font_color":"#353535","tab_hover_title_font_color":"#353535","tab_selected_title_font_color":"#353535","tab_selected_hover_title_font_color":"#353535","tab_active_title_font_color":"#353535","tab_active_hover_title_font_color":"#353535","tab_active_selected_title_font_color":"#353535","tab_selected_active_hover_title_font_color":"#353535","tab_filtered_title_font_color":"#353535","tab_filtered_hover_title_font_color":"#353535","tab_filtered_active_title_font_color":"#353535","tab_filtered_active_hover_title_font_color":"#353535","tab_filtered_selected_title_font_color":"#353535","tab_filtered_selected_hover_title_font_color":"#353535","tab_filtered_selected_active_title_font_color":"#353535","tab_filtered_selected_active_hover_title_font_color":"#353535","tab_filtered_highlighted_search_title_font_color":"#353535","tab_filtered_highlighted_search_hover_title_font_color":"#353535","tab_filtered_active_highlighted_search_title_font_color":"#353535","tab_filtered_active_highlighted_search_hover_title_font_color":"#353535","tab_filtered_selected_highlighted_search_title_font_color":"#353535","tab_filtered_selected_highlighted_search_hover_title_font_color":"#353535","tab_filtered_selected_active_highlighted_search_title_font_color":"#353535","tab_filtered_selected_active_highlighted_search_hover_title_font_color":"#353535","tab_filtered_background":"#f8ea45","tab_filtered_active_background":"#f8ea45","tab_filtered_selected_background":"#b4e817","tab_filtered_selected_hover_background":"#96c113","tab_filtered_selected_active_background":"#b4e817","tab_filtered_selected_active_hover_background":"#96c113","tab_filtered_selected_hover_border":"#96c113","tab_filtered_selected_active_hover_border":"#96c113","tab_filtered_selected_border":"#b4e817","tab_filtered_selected_active_border":"#b4e817","tab_filtered_border":"#f8ea45","tab_filtered_active_border":"#f8ea45","tab_filtered_hover_border":"#d2cb00","tab_filtered_active_hover_border":"#d2cb00","tab_filtered_highlighted_search_background":"#ffa500","tab_filtered_highlighted_search_border":"#ffa500","tab_filtered_active_highlighted_search_border":"#ffa500","tab_filtered_active_highlighted_search_background":"#ffa500","tab_filtered_selected_highlighted_search_background":"#ffa500","tab_filtered_selected_highlighted_search_border":"#ffa500","tab_filtered_selected_active_highlighted_search_background":"#ffa500","tab_filtered_selected_active_highlighted_search_border":"#ffa500","tab_filtered_highlighted_search_hover_background":"#d78b00","tab_filtered_highlighted_search_hover_border":"#d78b00","tab_filtered_active_highlighted_search_hover_background":"#d78b00","tab_filtered_active_highlighted_search_hover_border":"#d78b00","tab_filtered_selected_highlighted_search_hover_background":"#d78b00","tab_filtered_selected_highlighted_search_hover_border":"#d78b00","tab_filtered_selected_active_highlighted_search_hover_background":"#d78b00","tab_filtered_selected_active_highlighted_search_hover_border":"#d78b00","children_padding_left":"8px","tab_list_background":"#fafafa"},"TabsSizeSetNumber":2,"theme_name":"Light and blue (by Guibuu)","theme_version":2,"toolbar":"
","unused_buttons":"
"} \ No newline at end of file diff --git a/..Themes/dark flat with colors by kroppy.tt_theme b/..Themes/dark flat with colors by kroppy.tt_theme new file mode 100644 index 0000000..10ed3bc --- /dev/null +++ b/..Themes/dark flat with colors by kroppy.tt_theme @@ -0,0 +1 @@ +{"ColorsSet":{"active_font_weight":"normal","attention_background":"#cf4010","attention_border":"#cf4010","button_background":"#484848","button_border":"#484848","button_hover_background":"#292929","button_hover_border":"#353535","button_icons":"#9e9e9e","button_icons_hover":"#9e9e9e","children_padding_left":"11px","close_hover_background":"#939394","close_hover_border":"#757676","close_hover_x":"#fbfcfe","close_x":"#dddddd","drag_indicator":"#d1d1d1","expand_closed_background":"#818181","expand_closed_border":"#818181","expand_lines":"#9d9d9d","expand_open_background":"#339bf3","expand_open_border":"#339bf3","filter_box_background":"#3c3c3c","filter_box_border":"#616161","filter_box_font":"#adadad","filter_clear_icon":"#adadad","group_list_background":"#3c3c3c","group_list_borders":"#616161","group_list_button_hover_background":"#292929","group_list_default_font_color":"#b1b1b1","pin_list_background":"#3b3b3b","pin_list_border_bottom":"#616161","scrollbar_height":"11px","scrollbar_thumb":"#484848","scrollbar_thumb_hover":"#353535","scrollbar_track":"#3b3b3b","scrollbar_width":"12px","tab_active_background":"#d8751b","tab_active_border":"#d8751b","tab_active_hover_background":"#b86316","tab_active_hover_border":"#b86316","tab_active_hover_title_font_color":"#e8e8e8","tab_active_hover_title_font_weight":"bold","tab_active_selected_background":"#3f7ebe","tab_active_selected_border":"#3f7ebe","tab_active_selected_title_font_color":"#e8e8e8","tab_active_selected_title_font_weight":"bold","tab_active_title_font_color":"#e8e8e8","tab_active_title_font_weight":"bold","tab_background":"#3b3b3b","tab_border":"#3b3b3b","tab_discarded_background":"#3b3b3b","tab_discarded_border":"#3b3b3b","tab_discarded_hover_background":"#292929","tab_discarded_hover_border":"#292929","tab_discarded_hover_title_font_color":"#646464","tab_discarded_title_font_color":"#646464","tab_filtered":"#827e00","tab_filtered_active_border":"#d2cb00","tab_filtered_active_highlighted_search_border":"#ed9900","tab_filtered_active_highlighted_search_hover_border":"#c68100","tab_filtered_active_hover_border":"#d2cb00","tab_filtered_active_hover_title_font_color":"#000000","tab_filtered_active_hover_title_font_weight":"bold","tab_filtered_active_title_font_color":"#000000","tab_filtered_active_title_font_weight":"bold","tab_filtered_border":"#e8e000","tab_filtered_highlighted":"#b37400","tab_filtered_highlighted_search_border":"#ed9900","tab_filtered_highlighted_search_hover_border":"#c68100","tab_filtered_hover_border":"#d2cb00","tab_filtered_selected":"#0f8079","tab_filtered_selected_active":"#1299a9","tab_filtered_selected_active_border":"#0f8079","tab_filtered_selected_active_highlighted_search_border":"#ed9900","tab_filtered_selected_active_highlighted_search_hover_background":"#c68100","tab_filtered_selected_active_highlighted_search_hover_border":"#c68100","tab_filtered_selected_active_hover_border":"#0d6d67","tab_filtered_selected_active_hover_title_font_color":"#cfcfcf","tab_filtered_selected_active_hover_title_font_weight":"normal","tab_filtered_selected_active_title_font_color":"#cfcfcf","tab_filtered_selected_active_title_font_weight":"normal","tab_filtered_selected_border":"#0f8079","tab_filtered_selected_highlighted_search_border":"#ed9900","tab_filtered_selected_highlighted_search_hover_border":"#c68100","tab_filtered_selected_hover_border":"#0d6d67","tab_header_border_radius":"0px","tab_hover_background":"#292929","tab_hover_border":"#292929","tab_hover_title_font_color":"#9f9f9f","tab_hover_title_font_weight":"normal","tab_list_background":"#3b3b3b","tab_selected_active_hover_background":"#356a9f","tab_selected_active_hover_border":"#356a9f","tab_selected_active_hover_title_font_color":"#e8e8e8","tab_selected_active_hover_title_font_weight":"bold","tab_selected_background":"#3f7ebe","tab_selected_border":"#3f7ebe","tab_selected_discarded_background":"#3f7ebe","tab_selected_discarded_border":"#3f7ebe","tab_selected_discarded_hover_background":"#356a9f","tab_selected_discarded_hover_border":"#356a9f","tab_selected_discarded_hover_title_font_color":"#3f3f3f","tab_selected_discarded_title_font_color":"#3f3f3f","tab_selected_hover_background":"#356a9f","tab_selected_hover_border":"#356a9f","tab_selected_hover_title_font_color":"#c7c7c7","tab_selected_hover_title_font_weight":"normal","tab_selected_title_font_color":"#c1c1c1","tab_selected_title_font_weight":"normal","tab_title":"#adadad","tab_title_active":"#cacaca","tab_title_discarded":"#7e7e7e","tab_title_font_color":"#9f9f9f","tab_title_font_style":"normal","tab_title_font_weight":"normal","tabs_menu_background":"#484848","tabs_menu_border":"#616161","tabs_menu_font":"#bfbfbf","tabs_menu_hover_background":"#292929","tabs_menu_hover_border":"#353535","tabs_menu_separator":"#616161","toolbar_background":"#484848","toolbar_border_bottom":"#616161"},"TabsMargins":"1","TabsSizeSetNumber":2,"ToolbarShow":true,"theme_name":"dark flat with colors by kroppy","theme_version":3,"toolbar":"
","unused_buttons":""} \ No newline at end of file diff --git a/..Themes/legacy2 by luetage.tt_theme b/..Themes/legacy2 by luetage.tt_theme new file mode 100644 index 0000000..ea339a2 --- /dev/null +++ b/..Themes/legacy2 by luetage.tt_theme @@ -0,0 +1 @@ +{"ToolbarShow":true,"ColorsSet":{"scrollbar_thumb":"#c4c4c4","scrollbar_thumb_hover":"#787878","scrollbar_track":"#ffffff","toolbar_background":"#f6f6f6","toolbar_border_bottom":"#cccccc","button_border":"#f6f6f6","button_background":"#f6f6f6","button_hover_border":"#ecebee","button_hover_background":"#ecebee","button_icons":"#000000","filter_box_background":"#fafafa","filter_box_border":"#cccccc","filter_box_font":"#333333","filter_clear_icon":"#000000","pin_list_border_bottom":"#cccccc","pin_list_background":"#ffffff","tab_list_background":"#ffffff","tab_background":"#f6f6f6","tab_border":"#d2d2d2","tab_hover_background":"#d6d5d8","tab_hover_border":"#878787","tab_selected_background":"#f6f6f6","tab_selected_border":"#00caa7","tab_selected_hover_border":"#00caa7","tab_selected_hover_background":"#d6d5d8","tab_filtered":"#ffa53b","tab_filtered_highlighted":"#ff8628","tab_filtered_selected":"#fff422","tab_filtered_selected_active":"#fff422","active_font_weight":"bold","tab_title":"#000000","tab_title_active":"#000000","tab_title_discarded":"#7e7e7e","drag_indicator":"#00caa7","close_x":"#3b3b3d","close_hover_x":"#000000","close_hover_border":"#939394","close_hover_background":"#b0adbd","expand_open_border":"#129071","expand_open_background":"#00caa7","expand_closed_border":"#969696","expand_closed_background":"#020202","expand_lines":"#129071","tabs_menu_font":"#333333","tabs_menu_background":"#fafafa","tabs_menu_border":"#bebebe","tabs_menu_hover_background":"#efefef","tabs_menu_hover_border":"#bebebe","tabs_menu_separator":"#efefef","scrollbar_height":"4px","scrollbar_width":"8px","tab_filtered_selected_border":"#00caa7","tab_filtered_selected_active_border":"#00caa7","tab_filtered_selected_hover_border":"#00caa7","tab_filtered_selected_active_hover_border":"#00caa7","tab_filtered_selected_background":"#e8e000","tab_filtered_selected_active_hover_background":"#d2cb00","tab_filtered_selected_hover_background":"#d2cb00","tab_filtered_selected_active_background":"#e8e000","tab_filtered_selected_highlighted_search_border":"#00caa7","tab_filtered_selected_highlighted_search_hover_border":"#00caa7","tab_filtered_selected_active_highlighted_search_border":"#00caa7","tab_filtered_selected_active_highlighted_search_hover_border":"#00caa7","tab_active_hover_background":"#1de6b4","tab_active_background":"#c7f4e2","tab_active_border":"#bebebe","tab_active_hover_border":"#bebebe","tab_active_selected_background":"#c7f4e2","tab_selected_active_hover_background":"#1de6b4","tab_active_selected_border":"#00caa7","tab_selected_active_hover_border":"#00caa7","tab_selected_discarded_border":"#00caa7","tab_selected_discarded_hover_border":"#00caa7","tab_selected_discarded_background":"#f6f6f6","tab_selected_discarded_hover_background":"#d7d7d7","tab_discarded_background":"#f6f6f6","children_padding_left":"8px"},"TabsSizeSetNumber":2,"theme_name":"legacy by luetage","theme_version":2,"toolbar":"
","unused_buttons":""} \ No newline at end of file diff --git a/..files_ForTesting/manifest.json b/..files_ForTesting/manifest.json index 64c5cec..925573d 100644 --- a/..files_ForTesting/manifest.json +++ b/..files_ForTesting/manifest.json @@ -14,7 +14,7 @@ "19": "icons/16.png", "16": "icons/16.png" }, - "permissions": [ "tabs", "sessions", "", "storage" ], + "permissions": [ "tabs", "sessions", "", "storage", "bookmarks" ], "sidebar_action": { "default_icon": { diff --git a/..files_firefox/manifest.json b/..files_firefox/manifest.json index 46fd2a4..0b90591 100644 --- a/..files_firefox/manifest.json +++ b/..files_firefox/manifest.json @@ -14,7 +14,7 @@ "19": "icons/16.png", "16": "icons/16.png" }, - "permissions": [ "tabs", "sessions", "", "storage" ], + "permissions": [ "tabs", "sessions", "", "storage", "bookmarks" ], "sidebar_action": { "default_icon": { "16": "icons/16.png", @@ -44,5 +44,5 @@ "page": "options.html", "open_in_tab": true }, - "version": "1.3" + "version": "1.5" } \ No newline at end of file diff --git a/..files_opera/manifest.json b/..files_opera/manifest.json index 21972c4..9c297d5 100644 --- a/..files_opera/manifest.json +++ b/..files_opera/manifest.json @@ -15,7 +15,7 @@ "19": "icons/16.png", "16": "icons/16.png" }, - "permissions": [ "tabs", "sessions", "", "storage" ], + "permissions": [ "tabs", "sessions", "", "storage", "bookmarks" ], "sidebar_action": { "default_icon": { "19": "icons/16.png", diff --git a/..files_vivaldi/manifest.json b/..files_vivaldi/manifest.json index 7acbade..47600e2 100644 --- a/..files_vivaldi/manifest.json +++ b/..files_vivaldi/manifest.json @@ -14,7 +14,7 @@ "19": "icons/16.png", "16": "icons/16.png" }, - "permissions": [ "tabs", "sessions", "", "storage" ], + "permissions": [ "tabs", "sessions", "", "storage", "bookmarks" ], "options_ui": { "page": "options.html", "open_in_tab": false diff --git a/..legacy when needed/legacy.js b/..legacy when needed/legacy.js new file mode 100644 index 0000000..b781c36 --- /dev/null +++ b/..legacy when needed/legacy.js @@ -0,0 +1,347 @@ +// Copyright (c) 2017 kroppy. All rights reserved. +// Use of this source code is governed by a Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0) license +// that can be found at https://creativecommons.org/licenses/by-nc-nd/4.0/ + +function OldHashTab(tab){ + if (tabs[tab.id] == undefined){ + tabs[tab.id] = {ttid: "", hash: 0, h: 0, parent: tab.pinned ? "pin_list" : "tab_list", index: tab.index, expand: "n"}; + } + var hash = 0; + if (tab.url.length === 0){ + return 0; + } + for (var i = 0; i < tab.url.length; i++){ + hash = (hash << 5)-hash; + hash = hash+tab.url.charCodeAt(i); + hash |= 0; + } + tabs[tab.id].h = hash; +} + + +function LoadV015(retry){ + var loaded_options = {}; + for (var parameter in DefaultPreferences) { + opt[parameter] = DefaultPreferences[parameter]; + } + // set loaded options + if (localStorage.getItem("current_options") !== null){ + loaded_options = JSON.parse(localStorage["current_options"]); + } + for (var parameter in opt) { + if (loaded_options[parameter] != undefined && opt[parameter] != undefined){ + opt[parameter] = loaded_options[parameter]; + } + } + SavePreferences(); + if (localStorage.getItem("current_options") !== null){ + localStorage.removeItem("current_options"); + + } + + chrome.tabs.query({windowType: "normal"}, function(qtabs){ + // create current tabs object + qtabs.forEach(function(Tab){ + OldHashTab(Tab); + }); + + var reference_tabs = {}; + var tabs_to_save = []; + var tabs_matched = 0; + + // compare saved tabs from storage to current session tabs, but can be skipped if set in options + qtabs.forEach(function(Tab){ + for (var t = 0; t < 9999; t++){ + if (localStorage.getItem("t"+t) !== null){ + var LoadedTab = JSON.parse(localStorage["t"+t]); + if (LoadedTab[1] === tabs[Tab.id].h && reference_tabs[LoadedTab[0]] == undefined){ + reference_tabs[LoadedTab[0]] = Tab.id; + tabs[Tab.id].parent = LoadedTab[2]; + tabs[Tab.id].index = LoadedTab[3]; + tabs[Tab.id].expand = LoadedTab[4]; + tabs_matched++; + break; + } + + } else { + break; + } + + } + }); + + // replace parents tabIds to new ones, for that purpose reference_tabs was made before + for (var tabId in tabs){ + if (reference_tabs[tabs[tabId].parent] != undefined){ + tabs[tabId].parent = reference_tabs[tabs[tabId].parent]; + } + } + + if (browserId == "F") { + // append ids to firefox tabs + qtabs.forEach(function(Tab){ + AppendTabTTId(Tab.id); + }); + qtabs.forEach(function(Tab){ + tabs_to_save.push({id: Tab.id, ttid: tabs[tabId].ttid, parent: tabs[Tab.id].parent, index: tabs[Tab.id].index, expand: tabs[Tab.id].expand}); + }); + } else { + // create new hashes + qtabs.forEach(function(Tab){ + ChromeHashURL(Tab); + }); + qtabs.forEach(function(Tab){ + tabs_to_save.push({id: Tab.id, hash: tabs[Tab.id].hash, parent: tabs[Tab.id].parent, index: tabs[Tab.id].index, expand: tabs[Tab.id].expand}); + }); + } + localStorage["t_count"] = JSON.stringify(qtabs.length); + localStorage["tabs"] = JSON.stringify(tabs_to_save); + for (var t = 0; t < 9999; t++){ + if (localStorage.getItem("t"+t) !== null){ + localStorage.removeItem("t"+t); + } + } + window.location.reload(); + }); +} + +function FirefoxLoadV100(retry) { + chrome.windows.getAll({windowTypes: ["normal"], populate: true}, function(w) { + + var refTabs = {}; + var tabs_matched = 0; + var tabs_count = 0; + for (var wIndex = 0; wIndex < w.length; wIndex++) { + tabs_count += w[wIndex].tabs.length; + } + + // load tabs and windows from hdd + var LoadedWindows = LoadData("windows", []); + var LoadedTabs = LoadData("tabs", []); + + // if loaded tabs mismatch by 50%, then try to load back + if (LoadedTabs.length < tabs_count*0.5 || retry > 0) { + LoadedTabs = LoadData("tabs_BAK"+retry, []); + } + // if loaded windows mismatch, then try to load back + if (LoadedWindows.length < w.length || retry > 0) { + LoadedWindows = LoadData("windows_BAK"+retry, []); + } + // CACHED COUNTS AND STUFF + var lastWinId = w[w.length-1].id; + var lastTabId = w[w.length-1].tabs[w[w.length-1].tabs.length-1].id; + var LoadedWinCount = LoadedWindows.length; + var LoadedTabsCount = LoadedTabs.length; + var WinCount = w.length; + + for (var wIndex = 0; wIndex < WinCount; wIndex++) { + let winIndex = wIndex; + let winId = w[winIndex].id; + let tabsCount = w[winIndex].tabs.length; + + let win = Promise.resolve(browser.sessions.getWindowValue(winId, "TTId")).then(function(TTId) { // LOAD TTID FROM FIREFOX GET WINDOW VALUE + if (TTId != undefined) { + windows[winId] = {ttid: TTId, group_bar: opt.groups_toolbar_default, search_filter: "url", active_shelf: "", active_group: "tab_list", groups: {tab_list: {id: "tab_list", index: 0, activetab: 0, activetab_ttid: "", name: caption_ungrouped_group, font: ""}}, folders: {}}; + } else { + windows[winId] = {ttid: "", group_bar: opt.groups_toolbar_default, search_filter: "url", active_shelf: "", active_group: "tab_list", groups: {tab_list: {id: "tab_list", index: 0, activetab: 0, activetab_ttid: "", name: caption_ungrouped_group, font: ""}}, folders: {}}; + } + for (var tIndex = 0; tIndex < tabsCount; tIndex++) { + + let tabIndex = tIndex; + let tabId = w[winIndex].tabs[tabIndex].id; + let tabPinned = w[winIndex].tabs[tabIndex].pinned; + + let tab = Promise.resolve(browser.sessions.getTabValue(tabId, "TTId")).then(function(TTId) { // LOAD TTID FROM FIREFOX GET TAB VALUE + if (TTId != undefined) { + tabs[tabId] = {ttid: TTId, parent_ttid: "", parent: tabPinned ? "pin_list" : "tab_list", index: tabIndex, expand: "n"}; + } else { + tabs[tabId] = {ttid: "", parent_ttid: "", parent: tabPinned ? "pin_list" : "tab_list", index: tabIndex, expand: "n"}; + } + // IF ON LAST TAB AND LAST WINDOW, START MATCHING LOADED DATA + if (tabId == lastTabId && winId == lastWinId) { + for (var ThisSessonWinId in windows) { + if (windows[ThisSessonWinId].ttid != ""){ + for (var LwIndex = 0; LwIndex < LoadedWinCount; LwIndex++) { + if (LoadedWindows[LwIndex].ttid == windows[ThisSessonWinId].ttid) { + if (LoadedWindows[LwIndex].group_bar) { windows[ThisSessonWinId].group_bar = LoadedWindows[LwIndex].group_bar; } + if (LoadedWindows[LwIndex].search_filter) { windows[ThisSessonWinId].search_filter = LoadedWindows[LwIndex].search_filter; } + if (LoadedWindows[LwIndex].active_shelf) { windows[winId].active_shelf = LoadedWindows[LwIndex].active_shelf; } + if (LoadedWindows[LwIndex].active_group) { windows[ThisSessonWinId].active_group = LoadedWindows[LwIndex].active_group; } + if (Object.keys(LoadedWindows[LwIndex].groups).length > 0) { windows[ThisSessonWinId].groups = Object.assign({}, LoadedWindows[LwIndex].groups); } + if (Object.keys(LoadedWindows[LwIndex].folders).length > 0) { windows[ThisSessonWinId].folders = Object.assign({}, LoadedWindows[LwIndex].folders); } + LoadedWindows[LwIndex].ttid = ""; + break; + } + } + } else { + AppendWinTTId(parseInt(ThisSessonWinId)); + } + } + // OK, DONE WITH WINDOWS, START TABS LOOP + for (var ThisSessonTabId in tabs) { + if (tabs[ThisSessonTabId].ttid != ""){ + for (var LtabIndex = 0; LtabIndex < LoadedTabsCount; LtabIndex++) { + if (LoadedTabs[LtabIndex].ttid == tabs[ThisSessonTabId].ttid) { + refTabs[LoadedTabs[LtabIndex].id] = ThisSessonTabId; + if (LoadedTabs[LtabIndex].parent) { tabs[ThisSessonTabId].parent = LoadedTabs[LtabIndex].parent; } + if (LoadedTabs[LtabIndex].index) { tabs[ThisSessonTabId].index = LoadedTabs[LtabIndex].index; } + if (LoadedTabs[LtabIndex].expand) { tabs[ThisSessonTabId].expand = LoadedTabs[LtabIndex].expand; } + LoadedTabs[LtabIndex].ttid = ""; + tabs_matched++; + break; + } + } + } else { + AppendTabTTId(parseInt(ThisSessonTabId)); + } + } + // OK, DONE, NOW REPLACE OLD PARENTS IDS WITH THIS SESSION IDS + for (var ThisSessonTabId in tabs) { + if (refTabs[tabs[ThisSessonTabId].parent] != undefined) { + tabs[ThisSessonTabId].parent = refTabs[tabs[ThisSessonTabId].parent]; + } + } + // OK, SAME THING FOR ACTIVE TABS IN GROUPS + + for (var ThisSessonWinId in windows) { + for (var group in windows[ThisSessonWinId].groups) { + if (refTabs[windows[ThisSessonWinId].groups[group].activetab]) { + windows[ThisSessonWinId].groups[group].activetab = refTabs[windows[ThisSessonWinId].groups[group].activetab]; + } + } + } + + + if (localStorage.getItem("t_count") !== null){ + localStorage.removeItem("t_count"); + } + if (localStorage.getItem("tabs_BAK1") !== null){ + localStorage.removeItem("tabs_BAK1"); + } + if (localStorage.getItem("tabs_BAK2") !== null){ + localStorage.removeItem("tabs_BAK2"); + } + if (localStorage.getItem("tabs_BAK3") !== null){ + localStorage.removeItem("tabs_BAK3"); + } + if (localStorage.getItem("tabs") !== null){ + localStorage.removeItem("tabs"); + } + if (localStorage.getItem("windows") !== null){ + localStorage.removeItem(windows); + } + + + // will try to find tabs for 3 times + if (opt.skip_load == true || retry > 2 || (tabs_matched > tabs_count*0.5)) { + + running = true; + FirefoxAutoSaveData(); + FirefoxListeners(); + } else { + setTimeout(function() {FirefoxLoadTabs(retry+1);}, 2000); + } + + } + }); + } + }); + } + }); +} + + +function ConvertLegacyStorage() { + if (localStorage.getItem("current_theme") != null || localStorage.getItem("preferences") != null || localStorage.getItem("tabs") != null || localStorage.getItem("windows") != null) { + let current_theme = ""; + if (localStorage.getItem("current_theme") != null) { + current_theme = localStorage["current_theme"]; + } + let LSthemes = []; + if (localStorage.getItem("themes") != null) { + LSthemes = LoadData("themes", []); + } + SLThemes = {}; + LSthemes.forEach(function(themeName) { + let them = LoadData("theme"+themeName, {"TabsSizeSetNumber": 2, "ToolbarShow": true, "toolbar": DefaultToolbar}); + SLThemes[themeName] = them; + }); + + let LSpreferences = Object.assign({}, DefaultPreferences); + if (localStorage.getItem("preferences") != null) { + LSpreferences = LoadData("preferences", {}); + } + + if (browserId != "F") { + let LStabs = {}; + if (localStorage.getItem("tabs") != null) { + LStabs = LoadData("tabs", {}); + } + let LSwindows = {}; + if (localStorage.getItem("windows") != null) { + LSwindows = LoadData("windows", {}); + } + let LStabs_BAK1 = {}; + if (localStorage.getItem("tabs_BAK1") != null) { + LStabs_BAK1 = LoadData("tabs_BAK1", {}); + } + let LStabs_BAK2 = {}; + if (localStorage.getItem("tabs_BAK2") != null) { + LStabs_BAK2 = LoadData("tabs_BAK2", {}); + } + let LStabs_BAK3 = {}; + if (localStorage.getItem("tabs_BAK3") != null) { + LStabs_BAK3 = LoadData("tabs_BAK3", {}); + } + + let LSwindows_BAK1 = {}; + if (localStorage.getItem("windows_BAK1") != null) { + LSwindows_BAK1 = LoadData("windows_BAK1", {}); + } + let LSwindows_BAK2 = {}; + if (localStorage.getItem("windows_BAK2") != null) { + LSwindows_BAK2 = LoadData("windows_BAK2", {}); + } + let LSwindows_BAK3 = {}; + if (localStorage.getItem("windows_BAK3") != null) { + LSwindows_BAK3 = LoadData("windows_BAK3", {}); + } + + + let LSt_count = 0; + if (localStorage.getItem("t_count") != null) { + LSt_count = LoadData("t_count", {}); + } + let LSw_count = 0; + if (localStorage.getItem("w_count") != null) { + LSw_count = LoadData("w_count", {}); + } + chrome.storage.local.set({tabs: LStabs}); + chrome.storage.local.set({windows: LSwindows}); + chrome.storage.local.set({tabs_BAK1: LStabs_BAK1}); + chrome.storage.local.set({tabs_BAK2: LStabs_BAK2}); + chrome.storage.local.set({tabs_BAK3: LStabs_BAK3}); + + chrome.storage.local.set({windows_BAK1: LSwindows_BAK1}); + chrome.storage.local.set({windows_BAK2: LSwindows_BAK2}); + chrome.storage.local.set({windows_BAK3: LSwindows_BAK3}); + chrome.storage.local.set({t_count: LSt_count}); + chrome.storage.local.set({w_count: LSw_count}); + } + chrome.storage.local.set({preferences: LSpreferences}); + chrome.storage.local.set({current_theme: current_theme}); + chrome.storage.local.set({themes: SLThemes}); + localStorage.clear(); + window.location.reload(); + } +} + +function LoadData(KeyName, ExpectReturnDefaultType) { + var data = ExpectReturnDefaultType; + try { + data = JSON.parse(localStorage[KeyName]); + return data; + } catch(e) { + return ExpectReturnDefaultType; + } +} diff --git a/Tree Tabs.zip b/Tree Tabs.zip deleted file mode 100644 index 63f01db..0000000 Binary files a/Tree Tabs.zip and /dev/null differ diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 79881a0..1513461 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -19,6 +19,9 @@ "button_undo": { "message": "Reopen last closed" }, + "button_detach": { + "message": "Detach tab" + }, "button_move": { "message": "Detach tab" }, @@ -55,6 +58,9 @@ "button_extensions": { "message": "Extensions" }, + "button_unload": { + "message": "Unload tabs" + }, "button_discard": { "message": "Unload tabs" }, @@ -128,83 +134,102 @@ - "tabs_menu_expand_all": { + "menu_expand_all": { "message": "Expand all trees" }, - "tabs_menu_collapse_all": { + "menu_collapse_all": { "message": "Collapse all trees" }, - "tabs_menu_new": { + "menu_expand_tree": { + "message": "Expand tree" + }, + "menu_collapse_tree": { + "message": "Collapse tree" + }, + "menu_new_tab": { "message": "New tab" }, - "tabs_menu_clone": { + "menu_new_pin": { + "message": "New pinned tab" + }, + "menu_duplicate_tab": { "message": "Duplicate" }, - "tabs_menu_move": { + "menu_detach_tab": { "message": "Detach" }, - "tabs_menu_reload": { + "menu_reload_tab": { "message": "Reload" }, - "tabs_menu_pin": { + "menu_pin_tab": { "message": "Pin" }, - "tabs_menu_mute": { + "menu_mute_tab": { "message": "Mute" }, - "tabs_menu_unmute": { + "menu_mute_tree": { + "message": "Mute tree" + }, + "menu_unmute_tree": { + "message": "Unmute tree" + }, + "menu_unmute_tab": { "message": "Unmute" }, - "tabs_menu_mute_other": { + "menu_mute_other": { "message": "Mute other" }, - "tabs_menu_unmute_other": { + "menu_unmute_other": { "message": "Unmute other" }, - "tabs_menu_unpin": { + "menu_unpin_tab": { "message": "Unpin" }, - "tabs_menu_close_tree": { + "menu_close_tree": { "message": "Close tree" }, - "tabs_menu_close": { + "menu_close": { "message": "Close" }, - "tabs_menu_close_other": { + "menu_close_other": { "message": "Close other" }, - "tabs_menu_undo": { + "menu_undo_close_tab": { "message": "Undo close" }, - "tabs_menu_settings": { + "menu_treetabs_settings": { "message": "Settings" }, - "tabs_menu_discard": { + "menu_unload": { "message": "Unload" }, + "menu_bookmark_tree": { + "message": "Bookmark tree" + }, - "folders_menu_new_folder": { + + "menu_new_folder": { "message": "New folder" }, - "folders_menu_rename_folder": { + "menu_rename_folder": { "message": "Rename folder" }, - "folders_menu_delete": { + "menu_delete_folder": { "message": "Delete" }, - "groups_menu_new_group": { + "menu_new_group": { "message": "New group" }, - "groups_menu_rename": { + "menu_rename_group": { "message": "Rename group" }, - "groups_menu_delete": { + "menu_delete_group": { "message": "Delete group" }, - "groups_menu_delete_tabs_close": { + "menu_delete_group_tabs_close": { "message": "Delete group with tabs" }, @@ -212,6 +237,10 @@ "message": "Unload group" }, + "menu_bookmark_group": { + "message": "Bookmark group" + }, + @@ -238,38 +267,88 @@ "message": " Tabs " }, "options_syncro_tabbar_tabs_order": { - "message": "Synchronize browser tabs order with Tree Tabs, tabs can be unresponsive for a second after drag&drop. This option is needed for correct ctrl+tab switching" + "message": "Synchronize browser tabs order with Tree Tabs, tabs can be unresponsive for a second after drag&drop. This option is needed for correct ctrl+tab switching. You can disable this option if you don't use keyboard shortcuts." }, "options_switch_with_scroll": { "message": "Switch tabs with mouse wheel" }, - "options_close_with_MMB": { - "message": "Close tabs with middle mouse button" - }, + "options_always_show_close": { - "message": "Show close button on all tabs" + "message": "Show close button on all tabs and folders" }, "options_never_show_close": { - "message": "Don't show close button (option above will be ignored)" + "message": "Never show close button (option above will be ignored)" }, - "options_close_other_trees": { + "options_collapse_other_trees": { "message": "Automatically collapse other trees on expand" }, "options_open_tree_on_hover": { "message": "Auto expand collapsed trees when dragging and holding for a second over them" }, "options_promote_children": { - "message": "Promote children tabs on close, if disabled, when closing the parent of a tree structure, all tabs will be closed (be careful, because undo close tab will not recover the trees structure)" + "message": "Promote children on close, if disabled, when closing the parent of a tree structure, all tabs and folders will be closed (be careful, because undo close tab will not recover the trees structure)" }, "options_promote_children_in_first_child": { - "message": "Promote first child tab as a parent" + "message": "Promote first child as a parent" }, "options_skip_load": { "message": "Discard tree structure after browser's restart, this option is for those who don't use browser's session. Basically it disables loading database at startup." }, + + "options_midclick_tab": { + "message": "Action for middle mouse click on tab" + }, + "options_dbclick_tab": { + "message": "Action for double click on tab" + }, + + "options_action_tab_none": { + "message": "nothing" + }, + "options_action_tab_new": { + "message": "open new tab" + }, + "options_action_tab_expand_collapse": { + "message": "expand/collapse tree" + }, + "options_action_tab_close": { + "message": "close tab" + }, + "options_action_tab_reload": { + "message": "reload tab" + }, + "options_action_tab_unload": { + "message": "unload tab" + }, + "options_action_tab_activate_previous_active": { + "message": "go back to previous active tab (works only on unpinned tabs)" + }, + + + + + "options_midclick_group": { + "message": "Action for middle click on empty space on the left side or below the tabs" + }, + "options_dbclick_group": { + "message": "Action for double click on empty space on the left side or below the tabs" + }, + "options_action__group_none": { + "message": "nothing" + }, + "options_action__group_new": { + "message": "open new tab" + }, + "options_action__group_activate_previous_active": { + "message": "go back to previous active tab (works only on unpinned tabs)" + }, + + + + "options_append_child_tab": { "message": "Append children tabs at the" }, @@ -330,19 +409,22 @@ "options_append_child_tab_after_limit_bottom": { "message": "at the bottom" }, - "options_max_tree_drag_drop": { - "message": "Limit Drag&Drop to tree's maximum depth as well" - }, "options_show_counter_tabs": { - "message": "Show children tabs count on tab's title" + "message": "Show children tabs count on tabs and folders titles" }, "options_show_counter_tabs_hints": { - "message": "Show children tabs count in tab's hint" + "message": "Show children tabs count in tabs and folders hints" }, "options_max_tree_depth": { "message": "Maximum tree depth: set it to -1 for unlimited branches, 0 for flat tabs placement (no trees), any number above 0 will be its maximum" }, + "options_max_tree_drag_drop": { + "message": "Limit Drag&Drop to tree's maximum depth, so you can't drop tabs beyond maximum depth" + }, + "options_max_tree_drag_drop_folders": { + "message": "Limit Drag&Drop to tree's maximum depth, so you can't drop folders beyond maximum depth" + }, @@ -358,12 +440,47 @@ "message": "Show groups toolbar in new windows" }, "options_syncro_tabbar_groups_tabs_order": { - "message": "Synchronize browser tabs order after drag&drop of the group tabs. Tabs will sort for a long time, if browser has a lot of tabs open. This option is needed for correct ctrl+tab switching" + "message": "Synchronize browser tabs order after drag&drop of the group tabs. Tabs will sort for a long time, if browser has a lot of tabs open. This option is needed for correct ctrl+tab switching. You can disable this option if you don't use keyboard shortcuts." }, + "options_folders": { + "message": "Folders" + }, + + + "options_midclick_folder": { + "message": "Action for middle mouse click on folder" + }, + "options_dbclick_folder": { + "message": "Action for double click on folder" + }, + + "options_action_folder_none": { + "message": "nothing" + }, + "options_action_folder_rename": { + "message": "rename folder" + }, + "options_action_folder_new_folder": { + "message": "open new folder" + }, + "options_action_folder_new_tab": { + "message": "open new tab" + }, + "options_action_folder_expand_collapse": { + "message": "expand/collapse tree" + }, + "options_action_folder_close": { + "message": "close folder" + }, + "options_action_folder_unload": { + "message": "unload tabs in folder" + }, + + @@ -371,6 +488,13 @@ + + "options_global": { + "message": "Global" + }, + + + "options_theme": { "message": "Theme" }, @@ -424,6 +548,16 @@ + "options_tabs_margin_overlap": { + "message": "Tabs spacing:\nOverlap 1px, best for themes with borders" + }, + "options_tabs_margin_0": { + "message": "Tabs spacing:\nNo spacing, best for flat look" + }, + "options_tabs_margin_1": { + "message": "Tabs spacing:\nDefault, 1px between tabs" + }, + @@ -532,19 +666,82 @@ - "options_color_pick_filter_clear_icon": { - "message": "Clear search result x button color" - }, "close_x": { "message": "x inside the close button" }, "close_hover_x": { - "message": "x inside the close button on hover" + "message": "x inside the close button, on mouse hover" }, + + + "button_background": { + "message": "Toolbar buttons background" + }, + "button_hover_background": { + "message": "Toolbar buttons background, on mouse hover" + }, + + + "button_icons": { + "message": "Toolbar buttons icon color" + }, + "button_icons_hover": { + "message": "Toolbar buttons icon color, on mouse hover" + }, + "button_border": { + "message": "Toolbar buttons border color" + }, + "button_hover_border": { + "message": "Toolbar buttons border color, on mouse hover" + }, + + + "filter_box_font": { + "message": "Search box, font color" + }, + "filter_box_background": { + "message": "Search box, font background color" + }, + "filter_box_border": { + "message": "Search box, border color" + }, + "filter_clear_icon": { + "message": "Clear search result x button color" + }, + + + "toolbar_background": { + "message": "Toolbar background color" + }, + "toolbar_border_bottom": { + "message": "Toolbar borders color" + }, + + + + "attention_background": { + "message": "Tabs blinking for attention, background color" + }, + "attention_border": { + "message": "Tabs blinking for attention, border color" + }, + + + "pin_list_border_bottom": { + "message": "Pinned tabs list, border at the bottom color" + }, + "pin_list_background": { + "message": "Pinned tabs list, background color" + }, + + "options_color_pick_hover": { "message": "On hover" }, + + + "options_color_pick_border": { "message": "Border color" }, diff --git a/_locales/ru/messages.json b/_locales/ru/messages.json index 395a78f..1e8c132 100644 --- a/_locales/ru/messages.json +++ b/_locales/ru/messages.json @@ -2,6 +2,9 @@ "button_bookmarks": { "message": "Закладки" }, + "button_unload": { + "message": "Выгрузить все вкладки" + }, "button_discard": { "message": "Выгрузить все вкладки" }, @@ -20,6 +23,9 @@ "button_move": { "message": "Отсоединить текущую вкладку" }, + "button_detach": { + "message": "Отсоединить текущую вкладку" + }, "button_new": { "message": "ЛКМ - открыть новую вкладку \nСКМ - дублировать активную вкладку \nПКМ - прокрутка списка к активной вкладке" }, @@ -119,12 +125,10 @@ "options_append_orphan_tab_top": { "message": "в начале списка" }, - "options_close_other_trees": { + "options_collapse_other_trees": { "message": "автоматически сворачивать другие деревья при раскрывании дерева" }, - "options_close_with_MMB": { - "message": "закрывать вкладки средней кнопкой мыши" - }, + "options_color_button_background": { "message": " фон кнопки" }, @@ -374,55 +378,55 @@ "opt_url_for_web_panel": { "message": "Вставить этот URL в веб-панель" }, - "tabs_menu_clone": { + "menu_duplicate_tab": { "message": "Дублировать вкладку" }, - "tabs_menu_close": { + "menu_close": { "message": "Закрыть вкладку" }, - "tabs_menu_close_other": { + "menu_close_other": { "message": "Закрыть другие вкладки" }, - "tabs_menu_collapse_all": { + "menu_collapse_all": { "message": "Свернуть все деревья" }, - "tabs_menu_discard": { + "menu_unload": { "message": "Выгрузить вкладку" }, - "tabs_menu_expand_all": { + "menu_expand_all": { "message": "Раскрыть все деревья" }, - "tabs_menu_move": { + "menu_detach_tab": { "message": "Отсоединить вкладку" }, - "tabs_menu_mute": { + "menu_mute_tab": { "message": "Выключить звук на вкладке" }, - "tabs_menu_mute_other": { + "menu_mute_other": { "message": "Выключить звук (на других)" }, - "tabs_menu_new": { + "menu_new_tab": { "message": "Новая вкладка" }, - "tabs_menu_pin": { + "menu_pin_tab": { "message": "Закрепить вкладку" }, - "tabs_menu_reload": { + "menu_reload_tab": { "message": "Обновить вкладку" }, - "tabs_menu_settings": { + "menu_treetabs_settings": { "message": "Настройки Tree Tabs" }, - "tabs_menu_undo": { + "menu_undo_close_tab": { "message": "Отменить закрытие" }, - "tabs_menu_unmute": { + "menu_unmute_tab": { "message": "Включить звук на вкладке" }, - "tabs_menu_unmute_other": { + "menu_unmute_other": { "message": "Включить звук (на других)" }, - "tabs_menu_unpin": { + "menu_unpin_tab": { "message": "Открепить вкладку" }, "options_active_tab_font_bold": { @@ -434,7 +438,7 @@ "options_never_show_close": { "message": "не показывать кнопку закрытия (опция выше будет проигнорирована)" }, - "tabs_menu_close_tree": { + "menu_close_tree": { "message": "Закрыть дерево" } } diff --git a/background.html b/background.html index c97bdfc..f1c0516 100644 --- a/background.html +++ b/background.html @@ -3,6 +3,5 @@ - - + \ No newline at end of file diff --git a/bg_ch.js b/bg_ch.js index 3e7d97c..4d14af1 100644 --- a/bg_ch.js +++ b/bg_ch.js @@ -3,18 +3,31 @@ // that can be found at https://creativecommons.org/licenses/by-nc-nd/4.0/ if (browserId != "F") { - ConvertLegacyStorage(); - LoadPreferences(); - GetCurrentTheme(); + // ConvertLegacyStorage(); ChromeLoadTabs(0); ChromeMessageListeners(); } function ChromeLoadTabs(retry) { chrome.windows.getAll({windowTypes: ['normal'], populate: true}, function(w) { chrome.storage.local.get(null, function(storage) { + // LOAD PREFERENCES + opt = Object.assign({}, DefaultPreferences); + if (storage["preferences"]) { + for (var parameter in storage["preferences"]) { + if (opt[parameter] != undefined) { + opt[parameter] = storage["preferences"][parameter]; + } + } + } + // LOAD THEME + if (storage["current_theme"] && storage["themes"] && storage["themes"][storage["current_theme"]]) { + theme = storage["themes"][storage["current_theme"]]; + } else { + theme = Object.assign({}, DefaultTheme); + } + // load tabs and windows from storage var refTabs = {}; var tabs_matched = 0; - // load tabs and windows from storage.local var w_count = storage.w_count ? storage.w_count : 0; var t_count = storage.t_count ? storage.t_count : 0; var LoadedWindows = storage.windows ? storage.windows : []; @@ -36,7 +49,7 @@ function ChromeLoadTabs(retry) { let winId = w[wIndex].id; let url1 = w[wIndex].tabs[0].url; let url2 = w[wIndex].tabs[w[wIndex].tabs.length-1].url; - windows[winId] = {group_bar: opt.groups_toolbar_default, search_filter: "url", active_shelf: "", active_group: "tab_list", groups: {tab_list: {id: "tab_list", index: 0, active_tab: 0, name: caption_ungrouped_group, font: ""}}, folders: {}}; + windows[winId] = {group_bar: opt.groups_toolbar_default, search_filter: "url", active_shelf: "", active_group: "tab_list", groups: {tab_list: {id: "tab_list", index: 0, active_tab: 0, prev_active_tab: 0, name: caption_ungrouped_group, font: ""}}, folders: {}}; for (var LwIndex = 0; LwIndex < LoadedWinCount; LwIndex++) { if (LoadedWindows[LwIndex].url1 == url1 || LoadedWindows[LwIndex].url2 == url2) { if (LoadedWindows[LwIndex].group_bar) { windows[winId].group_bar = LoadedWindows[LwIndex].group_bar; } @@ -89,6 +102,9 @@ function ChromeLoadTabs(retry) { if (refTabs[windows[windowId].groups[group].active_tab]) { windows[windowId].groups[group].active_tab = refTabs[windows[windowId].groups[group].active_tab]; } + if (refTabs[windows[windowId].groups[group].prev_active_tab]) { + windows[windowId].groups[group].prev_active_tab = refTabs[windows[windowId].groups[group].prev_active_tab]; + } } } // will try to find tabs for 3 times @@ -170,7 +186,7 @@ async function ChromeAutoSaveData(BAK, LoopTimer) { } function ChromeHashURL(tab) { if (tabs[tab.id] == undefined) { - tabs[tab.id] = {hash: 0, parent: tab.pinned ? "pin_list" : "tab_list", index: tab.index, expand: "n"}; + tabs[tab.id] = {hash: 0, parent: tab.pinned ? "pin_list" : (windows[tab.windowId] ? windows[tab.windowId].active_group : "tab_list"), index: tab.index, expand: "n"}; } var hash = 0; for (var charIndex = 0; charIndex < tab.url.length; charIndex++) { @@ -246,7 +262,7 @@ function ChromeListeners() { // start all listeners chrome.runtime.sendMessage({command: "tab_activated", windowId: activeInfo.windowId, tabId: activeInfo.tabId}); }); chrome.windows.onCreated.addListener(function(window) { - windows[window.id] = {group_bar: opt.groups_toolbar_default, search_filter: "url", active_shelf: "", active_group: "tab_list", groups: {tab_list: {id: "tab_list", index: 0, active_tab: 0, name: caption_ungrouped_group, font: ""}}, folders: {}}; + windows[window.id] = {group_bar: opt.groups_toolbar_default, search_filter: "url", active_shelf: "", active_group: "tab_list", groups: {tab_list: {id: "tab_list", index: 0, active_tab: 0, prev_active_tab: 0, name: caption_ungrouped_group, font: ""}}, folders: {}}; schedule_save++; }); chrome.windows.onRemoved.addListener(function(windowId) { @@ -259,99 +275,151 @@ function ChromeListeners() { // start all listeners } function ChromeMessageListeners() { chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) { - log("message to background: "); - log(message); - switch(message.command) { - case "reload": - window.location.reload(); - break; - case "get_preferences": - sendResponse(opt); - break; - case "save_preferences": - opt = Object.assign({}, message.opt); - chrome.storage.local.set({preferences: message.opt}); - break; - case "get_windows": - sendResponse(windows); - break; - case "get_folders": - if (windows[message.windowId]) { - sendResponse(windows[message.windowId].folders); - } - break; - case "save_folders": + if (opt.debug) console.log("message to background:"); + if (opt.debug) console.log(message); + if (message.command == "reload") { + window.location.reload(); + return; + } + if (message.command == "get_preferences") { + sendResponse(opt); + return; + } + if (message.command == "save_preferences") { + opt = Object.assign({}, message.opt); + chrome.storage.local.set({preferences: message.opt}); + return; + } + if (message.command == "get_windows") { + sendResponse(windows); + return; + } + if (message.command == "get_folders") { + if (windows[message.windowId]) { + sendResponse(windows[message.windowId].folders); + } + return; + } + if (message.command == "save_folders") { + if (windows[message.windowId]) { windows[message.windowId].folders = Object.assign({}, message.folders); schedule_save++; - break; - case "get_groups": - if (windows[message.windowId]) { - sendResponse(windows[message.windowId].groups); - } - break; - case "save_groups": + } + return; + } + if (message.command == "get_groups") { + if (windows[message.windowId]) { + sendResponse(windows[message.windowId].groups); + } + return; + } + if (message.command == "save_groups") { + if (windows[message.windowId]) { windows[message.windowId].groups = Object.assign({}, message.groups); schedule_save++; - break; - case "set_active_group": + } + return; + } + if (message.command == "set_active_group") { + if (windows[message.windowId]) { windows[message.windowId].active_group = message.active_group; schedule_save++; - break; - case "get_active_group": - if (windows[message.windowId]) { - sendResponse(windows[message.windowId].active_group); - } - break; - case "set_search_filter": + } + return; + } + if (message.command == "get_active_group") { + if (windows[message.windowId]) { + sendResponse(windows[message.windowId].active_group); + } + return; + } + if (message.command == "set_search_filter") { + if (windows[message.windowId]) { windows[message.windowId].search_filter = message.search_filter; schedule_save++; - break; - case "get_search_filter": - if (windows[message.windowId]) { - sendResponse(windows[message.windowId].search_filter); - } - break; - case "set_active_shelf": + } + return; + } + if (message.command == "get_search_filter") { + if (windows[message.windowId]) { + sendResponse(windows[message.windowId].search_filter); + } + return; + } + if (message.command == "set_active_shelf") { + if (windows[message.windowId]) { windows[message.windowId].active_shelf = message.active_shelf; schedule_save++; - break; - case "get_active_shelf": - if (windows[message.windowId]) { - sendResponse(windows[message.windowId].active_shelf); - } - break; - case "set_group_bar": + } + return; + } + if (message.command == "get_active_shelf") { + if (windows[message.windowId]) { + sendResponse(windows[message.windowId].active_shelf); + } + return; + } + if (message.command == "set_group_bar") { + if (windows[message.windowId]) { windows[message.windowId].group_bar = message.group_bar; schedule_save++; - break; - case "get_group_bar": - if (windows[message.windowId]) { - sendResponse(windows[message.windowId].group_bar); + } + return; + } + if (message.command == "get_group_bar") { + if (windows[message.windowId]) { + sendResponse(windows[message.windowId].group_bar); + } + return; + } + if (message.command == "get_browser_tabs") { + sendResponse(tabs); + return; + } + if (message.command == "is_bg_ready") { + sendResponse(running); + return; + } + if (message.command == "update_tab") { + if (tabs[message.tabId]) { + if (message.tab.index) { + tabs[message.tabId].index = message.tab.index; } - break; - // case "console_log": - // console.log(message.m); - // break; - case "get_browser_tabs": - sendResponse(tabs); - break; - case "is_bg_ready": - sendResponse(running); - break; - case "update_tab": - if (tabs[message.tabId]) { - for (var parameter in message.tab) { - tabs[message.tabId][parameter] = message.tab[parameter]; - } - schedule_save++; + if (message.tab.expand) { + tabs[message.tabId].expand = message.tab.expand; } - break; - case "get_theme": - sendResponse(theme); - break; - case "reload_theme": - GetCurrentTheme(); - break; + if (message.tab.parent) { + tabs[message.tabId].parent = message.tab.parent; + } + schedule_save++; + } + return; + } + if (message.command == "update_all_tabs") { + for (let i = 0; i < message.pins.length; i++) { + if (tabs[message.pins[i].id]) { + tabs[message.pins[i].id].parent = "pin_list"; + tabs[message.pins[i].id].expand = ""; + tabs[message.pins[i].id].index = message.pins[i].index; + } + } + for (let j = 0; j < message.tabs.length; j++) { + if (tabs[message.tabs[j].id]) { + tabs[message.tabs[j].id].parent = message.tabs[j].parent; + tabs[message.tabs[j].id].expand = message.tabs[j].expand; + tabs[message.tabs[j].id].index = message.tabs[j].index; + } + } + schedule_save++; + return; + } + if (message.command == "get_theme") { + sendResponse(theme); + return; + } + if (message.command == "reload_theme") { + GetCurrentTheme(); + return; } }); } \ No newline at end of file diff --git a/bg_ff.js b/bg_ff.js index 2675db5..ba3703a 100644 --- a/bg_ff.js +++ b/bg_ff.js @@ -3,10 +3,7 @@ // that can be found at https://creativecommons.org/licenses/by-nc-nd/4.0/ if (browserId == "F") { - ConvertLegacyStorage(); FirefoxStart(0); - LoadPreferences(); - GetCurrentTheme(); FirefoxMessageListeners(); } function FirefoxStart(retry) { @@ -28,85 +25,105 @@ function FirefoxStart(retry) { } function FirefoxLoadTabs(retry) { chrome.windows.getAll({windowTypes: ["normal"], populate: true}, function(w) { - var tt_ids = {}; - var tabs_matched = 0; - var tabs_count = 0; - for (var wIndex = 0; wIndex < w.length; wIndex++) { - tabs_count += w[wIndex].tabs.length; - } - // CACHED COUNTS AND STUFF - var lastWinId = w[w.length-1].id; - var lastTabId = w[w.length-1].tabs[w[w.length-1].tabs.length-1].id; - var WinCount = w.length; - for (var wIndex = 0; wIndex < WinCount; wIndex++) { - let winIndex = wIndex; - let winId = w[winIndex].id; - let tabsCount = w[winIndex].tabs.length; - - // LOAD TTID FROM FIREFOX GET WINDOW VALUE - let win = Promise.resolve(browser.sessions.getWindowValue(winId, "TTdata")).then(function(WindowData) { - if (opt.skip_load == false && WindowData != undefined) { - windows[winId] = Object.assign({}, WindowData); - } else { - windows[winId] = {ttid: "", group_bar: opt.groups_toolbar_default, search_filter: "url", active_shelf: "", active_group: "tab_list", groups: {tab_list: {id: "tab_list", index: 0, active_tab: 0, active_tab_ttid: "", name: caption_ungrouped_group, font: ""}}, folders: {}}; + chrome.storage.local.get(null, function(storage) { + // LOAD PREFERENCES + opt = Object.assign({}, DefaultPreferences); + if (storage["preferences"]) { + for (var parameter in storage["preferences"]) { + if (opt[parameter] != undefined) { + opt[parameter] = storage["preferences"][parameter]; + } } - for (var tIndex = 0; tIndex < tabsCount; tIndex++) { - let tabIndex = tIndex; - let tabId = w[winIndex].tabs[tabIndex].id; - let tabPinned = w[winIndex].tabs[tabIndex].pinned; - // LOAD TTID FROM FIREFOX GET TAB VALUE - let tab = Promise.resolve(browser.sessions.getTabValue(tabId, "TTdata")).then(function(TabData) { - if (opt.skip_load == false && TabData != undefined) { - tabs[tabId] = Object.assign({}, TabData); - tt_ids[tabs[tabId].ttid] = tabId; - tabs_matched++; - } else { - tabs[tabId] = {ttid: "", parent_ttid: "", parent: tabPinned ? "pin_list" : "tab_list", index: tabIndex, expand: "n"}; - } - // IF ON LAST TAB AND LAST WINDOW, START MATCHING LOADED DATA - if (tabId == lastTabId && winId == lastWinId) { - for (var ThisSessonWinId in windows) { - if (windows[ThisSessonWinId].ttid == "") { - AppendWinTTId(parseInt(ThisSessonWinId)); - } + } + // LOAD THEME + if (storage["current_theme"] && storage["themes"] && storage["themes"][storage["current_theme"]]) { + theme = storage["themes"][storage["current_theme"]]; + } else { + theme = Object.assign({}, DefaultTheme); + } + // CACHED COUNTS AND STUFF + // var tt_ids = {}; + var tabs_matched = 0; + var tabs_count = 0; + for (var wIndex = 0; wIndex < w.length; wIndex++) { + tabs_count += w[wIndex].tabs.length; + } + var lastWinId = w[w.length-1].id; + var lastTabId = w[w.length-1].tabs[w[w.length-1].tabs.length-1].id; + var WinCount = w.length; + for (var wIndex = 0; wIndex < WinCount; wIndex++) { + let winIndex = wIndex; + let winId = w[winIndex].id; + let tabsCount = w[winIndex].tabs.length; + + // LOAD TTID FROM FIREFOX GET WINDOW VALUE + let win = Promise.resolve(browser.sessions.getWindowValue(winId, "TTdata")).then(function(WindowData) { + if (opt.skip_load == false && WindowData != undefined) { + windows[winId] = Object.assign({}, WindowData); + } else { + windows[winId] = {ttid: "", group_bar: opt.groups_toolbar_default, search_filter: "url", active_shelf: "", active_group: "tab_list", groups: {tab_list: {id: "tab_list", index: 0, active_tab: 0, active_tab_ttid: "", prev_active_tab: 0, prev_active_tab_ttid: "", name: caption_ungrouped_group, font: ""}}, folders: {}}; + } + for (var tIndex = 0; tIndex < tabsCount; tIndex++) { + let tabIndex = tIndex; + let tabId = w[winIndex].tabs[tabIndex].id; + let tabPinned = w[winIndex].tabs[tabIndex].pinned; + // LOAD TTID FROM FIREFOX GET TAB VALUE + let tab = Promise.resolve(browser.sessions.getTabValue(tabId, "TTdata")).then(function(TabData) { + if (opt.skip_load == false && TabData != undefined) { + tabs[tabId] = Object.assign({}, TabData); + tt_ids[tabs[tabId].ttid] = tabId; + tabs_matched++; + } else { + tabs[tabId] = {ttid: "", parent_ttid: "", parent: tabPinned ? "pin_list" : "tab_list", index: tabIndex, expand: ""}; } - // OK, DONE WITH WINDOWS, START TABS LOOP - for (var ThisSessonTabId in tabs) { - if (tabs[ThisSessonTabId].ttid == "") { - AppendTabTTId(parseInt(ThisSessonTabId)); - } - } - // OK, DONE, NOW REPLACE OLD PARENTS IDS WITH THIS SESSION IDS - for (var ThisSessonTabId in tabs) { - if (tt_ids[tabs[ThisSessonTabId].parent_ttid] != undefined) { - tabs[ThisSessonTabId].parent = tt_ids[tabs[ThisSessonTabId].parent_ttid]; - } - } - // OK, SAME THING FOR ACTIVE TABS IN GROUPS - for (var ThisSessonWinId in windows) { - for (var group in windows[ThisSessonWinId].groups) { - if (tt_ids[windows[ThisSessonWinId].groups[group].active_tab_ttid] != undefined) { - windows[ThisSessonWinId].groups[group].active_tab = tt_ids[windows[ThisSessonWinId].groups[group].active_tab_ttid]; + // IF ON LAST TAB AND LAST WINDOW, START MATCHING LOADED DATA + if (tabId == lastTabId && winId == lastWinId) { + for (var ThisSessonWinId in windows) { + if (windows[ThisSessonWinId].ttid == "") { + AppendWinTTId(parseInt(ThisSessonWinId)); } } + // OK, DONE WITH WINDOWS, START TABS LOOP + for (var ThisSessonTabId in tabs) { + if (tabs[ThisSessonTabId].ttid == "") { + AppendTabTTId(parseInt(ThisSessonTabId)); + } + } + // OK, DONE, NOW REPLACE OLD PARENTS IDS WITH THIS SESSION IDS + for (var ThisSessonTabId in tabs) { + if (tt_ids[tabs[ThisSessonTabId].parent_ttid] != undefined) { + tabs[ThisSessonTabId].parent = tt_ids[tabs[ThisSessonTabId].parent_ttid]; + } + } + // OK, SAME THING FOR ACTIVE TABS IN GROUPS + for (var ThisSessonWinId in windows) { + for (var group in windows[ThisSessonWinId].groups) { + if (tt_ids[windows[ThisSessonWinId].groups[group].active_tab_ttid] != undefined) { + windows[ThisSessonWinId].groups[group].active_tab = tt_ids[windows[ThisSessonWinId].groups[group].active_tab_ttid]; + } + if (tt_ids[windows[ThisSessonWinId].groups[group].prev_active_tab_ttid] != undefined) { + windows[ThisSessonWinId].groups[group].prev_active_tab = tt_ids[windows[ThisSessonWinId].groups[group].prev_active_tab_ttid]; + } + } + } + // will try to find tabs for 3 times + if (opt.skip_load == true || retry > 2 || (tabs_matched > tabs_count*0.5)) { + running = true; + // setInterval(function() { + FirefoxAutoSaveData(); + // }, 10000); + FirefoxListeners(); + } else { + setTimeout(function() { + FirefoxLoadTabs(retry+1); + }, 2000); + } } - // will try to find tabs for 3 times - if (opt.skip_load == true || retry > 2 || (tabs_matched > tabs_count*0.5)) { - running = true; - // setInterval(function() { - FirefoxAutoSaveData(); - // }, 10000); - FirefoxListeners(); - } else { - setTimeout(function() { - FirefoxLoadTabs(retry+1); - }, 2000); - } - } - }); - } - }); - } + }); + } + }); + } + }); }); } // save every second if there is anything to save obviously @@ -153,10 +170,13 @@ function GenerateNewWindowID() { function GenerateNewTabID() { var newID = "t_"+GenerateRandomID(); var newIdAvailable = true; - for (var tabId in tabs) { - if (tabs[tabId].ttid == newID) { - newIdAvailable = false; - } + // for (var tabId in tabs) { + // if (tabs[tabId].ttid == newID) { + // newIdAvailable = false; + // } + // } + if (tt_ids[newID] != undefined) { + newIdAvailable = false; } if (newIdAvailable) { return newID; @@ -169,8 +189,10 @@ function AppendTabTTId(tabId) { if (tabs[tabId] != undefined) { tabs[tabId].ttid = NewTTTabId; } else { - tabs[tabId] = {ttid: NewTTTabId, parent: "tab_list", parent_ttid: "", index: 0, expand: "n"}; + tabs[tabId] = {ttid: NewTTTabId, parent: "tab_list", parent_ttid: "", index: 0, expand: ""}; } + tt_ids[NewTTTabId] = tabId; + return NewTTTabId; // if (schedule_save > 0) browser.sessions.setTabValue( tabId, "TTdata", tabs[tabId] ); } @@ -179,7 +201,7 @@ function AppendWinTTId(windowId) { if (windows[windowId] != undefined) { windows[windowId].ttid = NewTTWindowId; } else { - windows[windowId] = {ttid: NewTTWindowId, group_bar: opt.groups_toolbar_default, search_filter: "url", active_shelf: "", active_group: "tab_list", groups: {tab_list: {id: "tab_list", index: 0, active_tab: 0, active_tab_ttid: "", name: caption_ungrouped_group, font: ""}}, folders: {}}; + windows[windowId] = {ttid: NewTTWindowId, group_bar: opt.groups_toolbar_default, search_filter: "url", active_shelf: "", active_group: "tab_list", groups: {tab_list: {id: "tab_list", index: 0, active_tab: 0, active_tab_ttid: "", prev_active_tab: 0, prev_active_tab_ttid: "", name: caption_ungrouped_group, font: ""}}, folders: {}}; } // if (schedule_save > 0) browser.sessions.setWindowValue( windowId, "TTdata", windows[windowId] ); } @@ -190,7 +212,7 @@ function ReplaceParents(oldTabId, newTabId) { } } } -var DETACHED_TABS___Bug1398272___WTF_ARE_YOU_DOING_MOZILLA = {}; +var DETACHED_TABS___Bug1398272___WTF_ARE_YOU_DOING_MOZILLA = {}; // MOZILLA BUG 1398272 // start all listeners function FirefoxListeners() { browser.browserAction.onClicked.addListener(function() { @@ -198,25 +220,29 @@ function FirefoxListeners() { browser.sidebarAction.open(); }); chrome.tabs.onCreated.addListener(function(tab) { - let t = Promise.resolve(browser.sessions.getTabValue(tab.id, "TTdata")).then(function(TabData) { - if (TabData != undefined) { - tabs[tab.id] = Object.assign({}, TabData); - } else { - AppendTabTTId(tab.id); - } - schedule_save++; + chrome.tabs.get(tab.id, function(NewTab) { // for some reason firefox sends tab with "active == false" even if tab is active (THIS IS POSSIBLY A NEW BUG IN FF 60.01!) + let t = Promise.resolve(browser.sessions.getTabValue(NewTab.id, "TTdata")).then(function(TabData) { + if (TabData != undefined) { + tabs[NewTab.id] = Object.assign({}, TabData); + let originalParent = TabData.parent_ttid == "" ? undefined : (tt_ids[TabData.parent_ttid] ? tt_ids[TabData.parent_ttid] : TabData.parent_ttid); + chrome.runtime.sendMessage({command: "tab_created", windowId: NewTab.windowId, tab: NewTab, tabId: NewTab.id, parentTabId: originalParent, index: TabData.index}); + } else { + AppendTabTTId(NewTab.id); + chrome.runtime.sendMessage({command: "tab_created", windowId: NewTab.windowId, tab: NewTab, tabId: NewTab.id}); + } + schedule_save++; + }); }); - chrome.runtime.sendMessage({command: "tab_created", windowId: tab.windowId, tab: tab, tabId: tab.id}); - schedule_save++; }); chrome.tabs.onAttached.addListener(function(tabId, attachInfo) { let oldId = tabId; chrome.tabs.get(oldId, function(tab) { ReplaceParents(oldId, tab.id); - tabs[tab.id] = tabs[oldId]; - DETACHED_TABS___Bug1398272___WTF_ARE_YOU_DOING_MOZILLA[oldId] = tab.id; - DETACHED_TABS___Bug1398272___WTF_ARE_YOU_DOING_MOZILLA[tab.id] = oldId; - browser.sessions.setTabValue( tab.id, "TTdata", tabs[oldId] ); + tt_ids[tabs[oldId].ttid] = tab.id; // MOZILLA BUG 1398272 + tabs[tab.id] = tabs[oldId]; // MOZILLA BUG 1398272 + DETACHED_TABS___Bug1398272___WTF_ARE_YOU_DOING_MOZILLA[oldId] = tab.id; // MOZILLA BUG 1398272 + DETACHED_TABS___Bug1398272___WTF_ARE_YOU_DOING_MOZILLA[tab.id] = oldId; // MOZILLA BUG 1398272 + browser.sessions.setTabValue( tab.id, "TTdata", tabs[oldId] ); // MOZILLA BUG 1398272 chrome.runtime.sendMessage({command: "tab_attached", windowId: attachInfo.newWindowId, tab: tab, tabId: tab.id, ParentId: tabs[tab.id].parent}); schedule_save++; }); @@ -225,17 +251,17 @@ function FirefoxListeners() { chrome.tabs.onDetached.addListener(function(tabId, detachInfo) { chrome.runtime.sendMessage({command: "tab_detached", windowId: detachInfo.oldWindowId, tabId: tabId}); let detachTabId = tabId; - if (DETACHED_TABS___Bug1398272___WTF_ARE_YOU_DOING_MOZILLA[tabId] != undefined) { - detachTabId = DETACHED_TABS___Bug1398272___WTF_ARE_YOU_DOING_MOZILLA[tabId]; - chrome.runtime.sendMessage({command: "tab_detached", windowId: detachInfo.oldWindowId, tabId: DETACHED_TABS___Bug1398272___WTF_ARE_YOU_DOING_MOZILLA[tabId]}); - } + if (DETACHED_TABS___Bug1398272___WTF_ARE_YOU_DOING_MOZILLA[tabId] != undefined) { // MOZILLA BUG 1398272 + detachTabId = DETACHED_TABS___Bug1398272___WTF_ARE_YOU_DOING_MOZILLA[tabId]; // MOZILLA BUG 1398272 + chrome.runtime.sendMessage({command: "tab_detached", windowId: detachInfo.oldWindowId, tabId: DETACHED_TABS___Bug1398272___WTF_ARE_YOU_DOING_MOZILLA[tabId]}); // MOZILLA BUG 1398272 + } // MOZILLA BUG 1398272 }); chrome.tabs.onRemoved.addListener(function(tabId, removeInfo) { setTimeout(function() { - if (DETACHED_TABS___Bug1398272___WTF_ARE_YOU_DOING_MOZILLA[tabId] != undefined) { - chrome.runtime.sendMessage({command: "tab_removed", windowId: removeInfo.windowId, tabId: DETACHED_TABS___Bug1398272___WTF_ARE_YOU_DOING_MOZILLA[tabId]}); - } + if (DETACHED_TABS___Bug1398272___WTF_ARE_YOU_DOING_MOZILLA[tabId] != undefined) { // MOZILLA BUG 1398272 + chrome.runtime.sendMessage({command: "tab_removed", windowId: removeInfo.windowId, tabId: DETACHED_TABS___Bug1398272___WTF_ARE_YOU_DOING_MOZILLA[tabId]}); // MOZILLA BUG 1398272 + } // MOZILLA BUG 1398272 chrome.runtime.sendMessage({command: "tab_removed", windowId: removeInfo.windowId, tabId: tabId}); }, 5); // setTimeout(function() { @@ -244,10 +270,12 @@ function FirefoxListeners() { schedule_save++; }); chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) { - if (changeInfo.pinned == true) { + if (changeInfo.pinned == true && tabs[tabId]) { tabs[tabId].parent = "pin_list"; tabs[tabId].parent_ttid = ""; schedule_save++; + } else { + AppendTabTTId(tabId); } if (changeInfo.title != undefined && !tab.active) { chrome.runtime.sendMessage({command: "tab_attention", windowId: tab.windowId, tabId: tabId}); @@ -265,6 +293,7 @@ function FirefoxListeners() { ReplaceParents(tabId, tab.id); chrome.runtime.sendMessage({command: "tab_removed", windowId: tab.windowId, tabId: removedTabId}); chrome.runtime.sendMessage({command: "tab_attached", windowId: tab.windowId, tab: tab, tabId: addedTabId, ParentId: tabs[addedTabId].parent}); + // delete ttid[tabs[removedTabId].ttid]; // delete tabs[removedTabId]; } setTimeout(function() { @@ -280,7 +309,7 @@ function FirefoxListeners() { chrome.windows.onCreated.addListener(function(window) { let win = Promise.resolve(browser.sessions.getWindowValue(window.id, "TTdata")).then(function(WindowData) { if (WindowData != undefined) { - windows[winId] = Object.assign({}, WindowData); + windows[window.id] = Object.assign({}, WindowData); } else { AppendWinTTId(window.id); } @@ -294,115 +323,170 @@ function FirefoxListeners() { } function FirefoxMessageListeners() { chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) { - log("message to background: "); - log(message); - switch(message.command) { - case "reload": - window.location.reload(); - break; - case "get_preferences": - sendResponse(opt); - break; - case "save_preferences": - opt = Object.assign({}, message.opt); - chrome.storage.local.set({preferences: message.opt}); - break; - case "get_windows": - sendResponse(windows); - break; - case "get_folders": - if (windows[message.windowId]) { - sendResponse(windows[message.windowId].folders); - } - break; - case "save_folders": + if (opt.debug) console.log("message to background:"); + if (opt.debug) console.log(message); + if (message.command == "reload") { + window.location.reload(); + return; + } + if (message.command == "get_preferences") { + sendResponse(opt); + return; + } + if (message.command == "save_preferences") { + opt = Object.assign({}, message.opt); + chrome.storage.local.set({preferences: message.opt}); + return; + } + if (message.command == "get_windows") { + sendResponse(windows); + return; + } + if (message.command == "get_folders") { + if (windows[message.windowId]) { + sendResponse(windows[message.windowId].folders); + } + return; + } + if (message.command == "save_folders") { + if (windows[message.windowId]) { windows[message.windowId].folders = Object.assign({}, message.folders); schedule_save++; - break; - case "get_groups": - if (windows[message.windowId]) { - sendResponse(windows[message.windowId].groups); - } - break; - case "save_groups": + } + return; + } + if (message.command == "get_groups") { + if (windows[message.windowId]) { + sendResponse(windows[message.windowId].groups); + } + return; + } + if (message.command == "save_groups") { + if (windows[message.windowId]) { windows[message.windowId].groups = Object.assign({}, message.groups); for (var group in windows[message.windowId].groups) { if (tabs[windows[message.windowId].groups[group].active_tab]) { windows[message.windowId].groups[group].active_tab_ttid = tabs[windows[message.windowId].groups[group].active_tab].ttid; } + if (tabs[windows[message.windowId].groups[group].prev_active_tab]) { + windows[message.windowId].groups[group].prev_active_tab_ttid = tabs[windows[message.windowId].groups[group].prev_active_tab].ttid; + } } schedule_save++; - break; - case "set_active_group": + } + return; + } + if (message.command == "set_active_group") { + if (windows[message.windowId]) { windows[message.windowId].active_group = message.active_group; schedule_save++; - break; - case "get_active_group": - if (windows[message.windowId]) { - sendResponse(windows[message.windowId].active_group); - } - break; - case "set_search_filter": + } + return; + } + if (message.command == "get_active_group") { + if (windows[message.windowId]) { + sendResponse(windows[message.windowId].active_group); + } + return; + } + if (message.command == "set_search_filter") { + if (windows[message.windowId]) { windows[message.windowId].search_filter = message.search_filter; schedule_save++; - break; - case "get_search_filter": - if (windows[message.windowId]) { - sendResponse(windows[message.windowId].search_filter); - } - break; - case "set_active_shelf": + } + return; + } + if (message.command == "get_search_filter") { + if (windows[message.windowId]) { + sendResponse(windows[message.windowId].search_filter); + } + return; + } + if (message.command == "set_active_shelf") { + if (windows[message.windowId]) { windows[message.windowId].active_shelf = message.active_shelf; schedule_save++; - break; - case "get_active_shelf": - if (windows[message.windowId]) { - sendResponse(windows[message.windowId].active_shelf); - } - break; - case "set_group_bar": + } + return; + } + if (message.command == "get_active_shelf") { + if (windows[message.windowId]) { + sendResponse(windows[message.windowId].active_shelf); + } + return; + } + if (message.command == "set_group_bar") { + if (windows[message.windowId]) { windows[message.windowId].group_bar = message.group_bar; schedule_save++; - break; - case "get_group_bar": - if (windows[message.windowId]) { - sendResponse(windows[message.windowId].group_bar); + } + return; + } + if (message.command == "get_group_bar") { + if (windows[message.windowId]) { + sendResponse(windows[message.windowId].group_bar); + } + return; + } + if (message.command == "get_browser_tabs") { + sendResponse(tabs); + return; + } + if (message.command == "is_bg_ready") { + sendResponse(running); + return; + } + if (message.command == "update_tab") { + if (tabs[message.tabId]) { + if (message.tab.index) { + tabs[message.tabId].index = message.tab.index; } - break; - // case "console_log": - // console.log(message.m); - // break; - case "get_browser_tabs": - sendResponse(tabs); - break; - case "is_bg_ready": - sendResponse(running); - break; - case "update_tab": - if (tabs[message.tabId]) { - if (message.tab.index) { - tabs[message.tabId].index = message.tab.index; - } - if (message.tab.expand) { - tabs[message.tabId].expand = message.tab.expand; - } - if (message.tab.parent) { - tabs[message.tabId].parent = message.tab.parent; - if (tabs[message.tab.parent]) { - tabs[message.tabId].parent_ttid = tabs[message.tab.parent].ttid; - } else { - tabs[message.tabId].parent_ttid = ""; - } - } - schedule_save++; + if (message.tab.expand) { + tabs[message.tabId].expand = message.tab.expand; } - break; - case "get_theme": - sendResponse(theme); - break; - case "reload_theme": - GetCurrentTheme(); - break; + if (message.tab.parent) { + tabs[message.tabId].parent = message.tab.parent; + if (tabs[message.tab.parent]) { + tabs[message.tabId].parent_ttid = tabs[message.tab.parent].ttid; + } else { + tabs[message.tabId].parent_ttid = ""; + } + } + schedule_save++; + } + return; + } + if (message.command == "update_all_tabs") { + for (let i = 0; i < message.pins.length; i++) { + if (tabs[message.pins[i].id]) { + tabs[message.pins[i].id].parent = "pin_list"; + tabs[message.pins[i].id].parent_ttid = ""; + tabs[message.pins[i].id].expand = ""; + tabs[message.pins[i].id].index = message.pins[i].index; + } + } + for (let j = 0; j < message.tabs.length; j++) { + if (tabs[message.tabs[j].id]) { + tabs[message.tabs[j].id].parent = message.tabs[j].parent; + tabs[message.tabs[j].id].expand = message.tabs[j].expand; + tabs[message.tabs[j].id].index = message.tabs[j].index; + if (tabs[message.tabs[j].parent]) { + tabs[message.tabs[j].id].parent_ttid = tabs[message.tabs[j].parent].ttid; + } else { + tabs[message.tabs[j].id].parent_ttid = AppendTabTTId(message.tabs[j].parent); + } + } + } + schedule_save++; + return; + } + if (message.command == "get_theme") { + sendResponse(theme); + return; + } + if (message.command == "reload_theme") { + GetCurrentTheme(); + return; } }); } \ No newline at end of file diff --git a/download.html b/download.html new file mode 100644 index 0000000..004bf9d --- /dev/null +++ b/download.html @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/download.js b/download.js new file mode 100644 index 0000000..4aeb12b --- /dev/null +++ b/download.js @@ -0,0 +1,18 @@ +chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) { + if (message.command == "show_save_file_dialog") { + let file = new File([JSON.stringify(message.data)], message.filename, {type: "text/csv;charset=utf-8"} ); + let body = document.getElementById("body"); + let savelink = document.createElement("a"); + savelink.target = "_blank"; + savelink.style.display = "none"; + savelink.type = "file"; + savelink.download = message.filename; + savelink.href = URL.createObjectURL(file); + body.appendChild(savelink); + savelink.click(); + setTimeout(function() { + chrome.tabs.update(message.currentTabId, { active: true }); + chrome.tabs.remove(message.selfTabId, null); + }, 50); + } +}); diff --git a/legacy.js b/legacy.js index b781c36..ae4358b 100644 --- a/legacy.js +++ b/legacy.js @@ -4,7 +4,7 @@ function OldHashTab(tab){ if (tabs[tab.id] == undefined){ - tabs[tab.id] = {ttid: "", hash: 0, h: 0, parent: tab.pinned ? "pin_list" : "tab_list", index: tab.index, expand: "n"}; + tabs[tab.id] = {ttid: "", hash: 0, h: 0, parent: tab.pinned ? "pin_list" : "tab_list", index: tab.index, expand: ""}; } var hash = 0; if (tab.url.length === 0){ @@ -153,9 +153,9 @@ function FirefoxLoadV100(retry) { let tab = Promise.resolve(browser.sessions.getTabValue(tabId, "TTId")).then(function(TTId) { // LOAD TTID FROM FIREFOX GET TAB VALUE if (TTId != undefined) { - tabs[tabId] = {ttid: TTId, parent_ttid: "", parent: tabPinned ? "pin_list" : "tab_list", index: tabIndex, expand: "n"}; + tabs[tabId] = {ttid: TTId, parent_ttid: "", parent: tabPinned ? "pin_list" : "tab_list", index: tabIndex, expand: ""}; } else { - tabs[tabId] = {ttid: "", parent_ttid: "", parent: tabPinned ? "pin_list" : "tab_list", index: tabIndex, expand: "n"}; + tabs[tabId] = {ttid: "", parent_ttid: "", parent: tabPinned ? "pin_list" : "tab_list", index: tabIndex, expand: ""}; } // IF ON LAST TAB AND LAST WINDOW, START MATCHING LOADED DATA if (tabId == lastTabId && winId == lastWinId) { diff --git a/lib_jquery/jquery-3.2.1.min.js b/lib_jquery/jquery-3.2.1.min.js deleted file mode 100644 index 644d35e..0000000 --- a/lib_jquery/jquery-3.2.1.min.js +++ /dev/null @@ -1,4 +0,0 @@ -/*! jQuery v3.2.1 | (c) JS Foundation and other contributors | jquery.org/license */ -!function(a,b){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){"use strict";var c=[],d=a.document,e=Object.getPrototypeOf,f=c.slice,g=c.concat,h=c.push,i=c.indexOf,j={},k=j.toString,l=j.hasOwnProperty,m=l.toString,n=m.call(Object),o={};function p(a,b){b=b||d;var c=b.createElement("script");c.text=a,b.head.appendChild(c).parentNode.removeChild(c)}var q="3.2.1",r=function(a,b){return new r.fn.init(a,b)},s=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,t=/^-ms-/,u=/-([a-z])/g,v=function(a,b){return b.toUpperCase()};r.fn=r.prototype={jquery:q,constructor:r,length:0,toArray:function(){return f.call(this)},get:function(a){return null==a?f.call(this):a<0?this[a+this.length]:this[a]},pushStack:function(a){var b=r.merge(this.constructor(),a);return b.prevObject=this,b},each:function(a){return r.each(this,a)},map:function(a){return this.pushStack(r.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(f.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(a<0?b:0);return this.pushStack(c>=0&&c0&&b-1 in a)}var x=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u="sizzle"+1*new Date,v=a.document,w=0,x=0,y=ha(),z=ha(),A=ha(),B=function(a,b){return a===b&&(l=!0),0},C={}.hasOwnProperty,D=[],E=D.pop,F=D.push,G=D.push,H=D.slice,I=function(a,b){for(var c=0,d=a.length;c+~]|"+K+")"+K+"*"),S=new RegExp("="+K+"*([^\\]'\"]*?)"+K+"*\\]","g"),T=new RegExp(N),U=new RegExp("^"+L+"$"),V={ID:new RegExp("^#("+L+")"),CLASS:new RegExp("^\\.("+L+")"),TAG:new RegExp("^("+L+"|[*])"),ATTR:new RegExp("^"+M),PSEUDO:new RegExp("^"+N),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+K+"*(even|odd|(([+-]|)(\\d*)n|)"+K+"*(?:([+-]|)"+K+"*(\\d+)|))"+K+"*\\)|)","i"),bool:new RegExp("^(?:"+J+")$","i"),needsContext:new RegExp("^"+K+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+K+"*((?:-\\d)?\\d*)"+K+"*\\)|)(?=[^-]|$)","i")},W=/^(?:input|select|textarea|button)$/i,X=/^h\d$/i,Y=/^[^{]+\{\s*\[native \w/,Z=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,$=/[+~]/,_=new RegExp("\\\\([\\da-f]{1,6}"+K+"?|("+K+")|.)","ig"),aa=function(a,b,c){var d="0x"+b-65536;return d!==d||c?b:d<0?String.fromCharCode(d+65536):String.fromCharCode(d>>10|55296,1023&d|56320)},ba=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,ca=function(a,b){return b?"\0"===a?"\ufffd":a.slice(0,-1)+"\\"+a.charCodeAt(a.length-1).toString(16)+" ":"\\"+a},da=function(){m()},ea=ta(function(a){return a.disabled===!0&&("form"in a||"label"in a)},{dir:"parentNode",next:"legend"});try{G.apply(D=H.call(v.childNodes),v.childNodes),D[v.childNodes.length].nodeType}catch(fa){G={apply:D.length?function(a,b){F.apply(a,H.call(b))}:function(a,b){var c=a.length,d=0;while(a[c++]=b[d++]);a.length=c-1}}}function ga(a,b,d,e){var f,h,j,k,l,o,r,s=b&&b.ownerDocument,w=b?b.nodeType:9;if(d=d||[],"string"!=typeof a||!a||1!==w&&9!==w&&11!==w)return d;if(!e&&((b?b.ownerDocument||b:v)!==n&&m(b),b=b||n,p)){if(11!==w&&(l=Z.exec(a)))if(f=l[1]){if(9===w){if(!(j=b.getElementById(f)))return d;if(j.id===f)return d.push(j),d}else if(s&&(j=s.getElementById(f))&&t(b,j)&&j.id===f)return d.push(j),d}else{if(l[2])return G.apply(d,b.getElementsByTagName(a)),d;if((f=l[3])&&c.getElementsByClassName&&b.getElementsByClassName)return G.apply(d,b.getElementsByClassName(f)),d}if(c.qsa&&!A[a+" "]&&(!q||!q.test(a))){if(1!==w)s=b,r=a;else if("object"!==b.nodeName.toLowerCase()){(k=b.getAttribute("id"))?k=k.replace(ba,ca):b.setAttribute("id",k=u),o=g(a),h=o.length;while(h--)o[h]="#"+k+" "+sa(o[h]);r=o.join(","),s=$.test(a)&&qa(b.parentNode)||b}if(r)try{return G.apply(d,s.querySelectorAll(r)),d}catch(x){}finally{k===u&&b.removeAttribute("id")}}}return i(a.replace(P,"$1"),b,d,e)}function ha(){var a=[];function b(c,e){return a.push(c+" ")>d.cacheLength&&delete b[a.shift()],b[c+" "]=e}return b}function ia(a){return a[u]=!0,a}function ja(a){var b=n.createElement("fieldset");try{return!!a(b)}catch(c){return!1}finally{b.parentNode&&b.parentNode.removeChild(b),b=null}}function ka(a,b){var c=a.split("|"),e=c.length;while(e--)d.attrHandle[c[e]]=b}function la(a,b){var c=b&&a,d=c&&1===a.nodeType&&1===b.nodeType&&a.sourceIndex-b.sourceIndex;if(d)return d;if(c)while(c=c.nextSibling)if(c===b)return-1;return a?1:-1}function ma(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function na(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function oa(a){return function(b){return"form"in b?b.parentNode&&b.disabled===!1?"label"in b?"label"in b.parentNode?b.parentNode.disabled===a:b.disabled===a:b.isDisabled===a||b.isDisabled!==!a&&ea(b)===a:b.disabled===a:"label"in b&&b.disabled===a}}function pa(a){return ia(function(b){return b=+b,ia(function(c,d){var e,f=a([],c.length,b),g=f.length;while(g--)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function qa(a){return a&&"undefined"!=typeof a.getElementsByTagName&&a}c=ga.support={},f=ga.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return!!b&&"HTML"!==b.nodeName},m=ga.setDocument=function(a){var b,e,g=a?a.ownerDocument||a:v;return g!==n&&9===g.nodeType&&g.documentElement?(n=g,o=n.documentElement,p=!f(n),v!==n&&(e=n.defaultView)&&e.top!==e&&(e.addEventListener?e.addEventListener("unload",da,!1):e.attachEvent&&e.attachEvent("onunload",da)),c.attributes=ja(function(a){return a.className="i",!a.getAttribute("className")}),c.getElementsByTagName=ja(function(a){return a.appendChild(n.createComment("")),!a.getElementsByTagName("*").length}),c.getElementsByClassName=Y.test(n.getElementsByClassName),c.getById=ja(function(a){return o.appendChild(a).id=u,!n.getElementsByName||!n.getElementsByName(u).length}),c.getById?(d.filter.ID=function(a){var b=a.replace(_,aa);return function(a){return a.getAttribute("id")===b}},d.find.ID=function(a,b){if("undefined"!=typeof b.getElementById&&p){var c=b.getElementById(a);return c?[c]:[]}}):(d.filter.ID=function(a){var b=a.replace(_,aa);return function(a){var c="undefined"!=typeof a.getAttributeNode&&a.getAttributeNode("id");return c&&c.value===b}},d.find.ID=function(a,b){if("undefined"!=typeof b.getElementById&&p){var c,d,e,f=b.getElementById(a);if(f){if(c=f.getAttributeNode("id"),c&&c.value===a)return[f];e=b.getElementsByName(a),d=0;while(f=e[d++])if(c=f.getAttributeNode("id"),c&&c.value===a)return[f]}return[]}}),d.find.TAG=c.getElementsByTagName?function(a,b){return"undefined"!=typeof b.getElementsByTagName?b.getElementsByTagName(a):c.qsa?b.querySelectorAll(a):void 0}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){while(c=f[e++])1===c.nodeType&&d.push(c);return d}return f},d.find.CLASS=c.getElementsByClassName&&function(a,b){if("undefined"!=typeof b.getElementsByClassName&&p)return b.getElementsByClassName(a)},r=[],q=[],(c.qsa=Y.test(n.querySelectorAll))&&(ja(function(a){o.appendChild(a).innerHTML="",a.querySelectorAll("[msallowcapture^='']").length&&q.push("[*^$]="+K+"*(?:''|\"\")"),a.querySelectorAll("[selected]").length||q.push("\\["+K+"*(?:value|"+J+")"),a.querySelectorAll("[id~="+u+"-]").length||q.push("~="),a.querySelectorAll(":checked").length||q.push(":checked"),a.querySelectorAll("a#"+u+"+*").length||q.push(".#.+[+~]")}),ja(function(a){a.innerHTML="";var b=n.createElement("input");b.setAttribute("type","hidden"),a.appendChild(b).setAttribute("name","D"),a.querySelectorAll("[name=d]").length&&q.push("name"+K+"*[*^$|!~]?="),2!==a.querySelectorAll(":enabled").length&&q.push(":enabled",":disabled"),o.appendChild(a).disabled=!0,2!==a.querySelectorAll(":disabled").length&&q.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),q.push(",.*:")})),(c.matchesSelector=Y.test(s=o.matches||o.webkitMatchesSelector||o.mozMatchesSelector||o.oMatchesSelector||o.msMatchesSelector))&&ja(function(a){c.disconnectedMatch=s.call(a,"*"),s.call(a,"[s!='']:x"),r.push("!=",N)}),q=q.length&&new RegExp(q.join("|")),r=r.length&&new RegExp(r.join("|")),b=Y.test(o.compareDocumentPosition),t=b||Y.test(o.contains)?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)while(b=b.parentNode)if(b===a)return!0;return!1},B=b?function(a,b){if(a===b)return l=!0,0;var d=!a.compareDocumentPosition-!b.compareDocumentPosition;return d?d:(d=(a.ownerDocument||a)===(b.ownerDocument||b)?a.compareDocumentPosition(b):1,1&d||!c.sortDetached&&b.compareDocumentPosition(a)===d?a===n||a.ownerDocument===v&&t(v,a)?-1:b===n||b.ownerDocument===v&&t(v,b)?1:k?I(k,a)-I(k,b):0:4&d?-1:1)}:function(a,b){if(a===b)return l=!0,0;var c,d=0,e=a.parentNode,f=b.parentNode,g=[a],h=[b];if(!e||!f)return a===n?-1:b===n?1:e?-1:f?1:k?I(k,a)-I(k,b):0;if(e===f)return la(a,b);c=a;while(c=c.parentNode)g.unshift(c);c=b;while(c=c.parentNode)h.unshift(c);while(g[d]===h[d])d++;return d?la(g[d],h[d]):g[d]===v?-1:h[d]===v?1:0},n):n},ga.matches=function(a,b){return ga(a,null,null,b)},ga.matchesSelector=function(a,b){if((a.ownerDocument||a)!==n&&m(a),b=b.replace(S,"='$1']"),c.matchesSelector&&p&&!A[b+" "]&&(!r||!r.test(b))&&(!q||!q.test(b)))try{var d=s.call(a,b);if(d||c.disconnectedMatch||a.document&&11!==a.document.nodeType)return d}catch(e){}return ga(b,n,null,[a]).length>0},ga.contains=function(a,b){return(a.ownerDocument||a)!==n&&m(a),t(a,b)},ga.attr=function(a,b){(a.ownerDocument||a)!==n&&m(a);var e=d.attrHandle[b.toLowerCase()],f=e&&C.call(d.attrHandle,b.toLowerCase())?e(a,b,!p):void 0;return void 0!==f?f:c.attributes||!p?a.getAttribute(b):(f=a.getAttributeNode(b))&&f.specified?f.value:null},ga.escape=function(a){return(a+"").replace(ba,ca)},ga.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},ga.uniqueSort=function(a){var b,d=[],e=0,f=0;if(l=!c.detectDuplicates,k=!c.sortStable&&a.slice(0),a.sort(B),l){while(b=a[f++])b===a[f]&&(e=d.push(f));while(e--)a.splice(d[e],1)}return k=null,a},e=ga.getText=function(a){var b,c="",d=0,f=a.nodeType;if(f){if(1===f||9===f||11===f){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=e(a)}else if(3===f||4===f)return a.nodeValue}else while(b=a[d++])c+=e(b);return c},d=ga.selectors={cacheLength:50,createPseudo:ia,match:V,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(_,aa),a[3]=(a[3]||a[4]||a[5]||"").replace(_,aa),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),"nth"===a[1].slice(0,3)?(a[3]||ga.error(a[0]),a[4]=+(a[4]?a[5]+(a[6]||1):2*("even"===a[3]||"odd"===a[3])),a[5]=+(a[7]+a[8]||"odd"===a[3])):a[3]&&ga.error(a[0]),a},PSEUDO:function(a){var b,c=!a[6]&&a[2];return V.CHILD.test(a[0])?null:(a[3]?a[2]=a[4]||a[5]||"":c&&T.test(c)&&(b=g(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){var b=a.replace(_,aa).toLowerCase();return"*"===a?function(){return!0}:function(a){return a.nodeName&&a.nodeName.toLowerCase()===b}},CLASS:function(a){var b=y[a+" "];return b||(b=new RegExp("(^|"+K+")"+a+"("+K+"|$)"))&&y(a,function(a){return b.test("string"==typeof a.className&&a.className||"undefined"!=typeof a.getAttribute&&a.getAttribute("class")||"")})},ATTR:function(a,b,c){return function(d){var e=ga.attr(d,a);return null==e?"!="===b:!b||(e+="","="===b?e===c:"!="===b?e!==c:"^="===b?c&&0===e.indexOf(c):"*="===b?c&&e.indexOf(c)>-1:"$="===b?c&&e.slice(-c.length)===c:"~="===b?(" "+e.replace(O," ")+" ").indexOf(c)>-1:"|="===b&&(e===c||e.slice(0,c.length+1)===c+"-"))}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),s=!i&&!h,t=!1;if(q){if(f){while(p){m=b;while(m=m[p])if(h?m.nodeName.toLowerCase()===r:1===m.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&s){m=q,l=m[u]||(m[u]={}),k=l[m.uniqueID]||(l[m.uniqueID]={}),j=k[a]||[],n=j[0]===w&&j[1],t=n&&j[2],m=n&&q.childNodes[n];while(m=++n&&m&&m[p]||(t=n=0)||o.pop())if(1===m.nodeType&&++t&&m===b){k[a]=[w,n,t];break}}else if(s&&(m=b,l=m[u]||(m[u]={}),k=l[m.uniqueID]||(l[m.uniqueID]={}),j=k[a]||[],n=j[0]===w&&j[1],t=n),t===!1)while(m=++n&&m&&m[p]||(t=n=0)||o.pop())if((h?m.nodeName.toLowerCase()===r:1===m.nodeType)&&++t&&(s&&(l=m[u]||(m[u]={}),k=l[m.uniqueID]||(l[m.uniqueID]={}),k[a]=[w,t]),m===b))break;return t-=e,t===d||t%d===0&&t/d>=0}}},PSEUDO:function(a,b){var c,e=d.pseudos[a]||d.setFilters[a.toLowerCase()]||ga.error("unsupported pseudo: "+a);return e[u]?e(b):e.length>1?(c=[a,a,"",b],d.setFilters.hasOwnProperty(a.toLowerCase())?ia(function(a,c){var d,f=e(a,b),g=f.length;while(g--)d=I(a,f[g]),a[d]=!(c[d]=f[g])}):function(a){return e(a,0,c)}):e}},pseudos:{not:ia(function(a){var b=[],c=[],d=h(a.replace(P,"$1"));return d[u]?ia(function(a,b,c,e){var f,g=d(a,null,e,[]),h=a.length;while(h--)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,e,f){return b[0]=a,d(b,null,f,c),b[0]=null,!c.pop()}}),has:ia(function(a){return function(b){return ga(a,b).length>0}}),contains:ia(function(a){return a=a.replace(_,aa),function(b){return(b.textContent||b.innerText||e(b)).indexOf(a)>-1}}),lang:ia(function(a){return U.test(a||"")||ga.error("unsupported lang: "+a),a=a.replace(_,aa).toLowerCase(),function(b){var c;do if(c=p?b.lang:b.getAttribute("xml:lang")||b.getAttribute("lang"))return c=c.toLowerCase(),c===a||0===c.indexOf(a+"-");while((b=b.parentNode)&&1===b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)===b.id},root:function(a){return a===o},focus:function(a){return a===n.activeElement&&(!n.hasFocus||n.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:oa(!1),disabled:oa(!0),checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeType<6)return!1;return!0},parent:function(a){return!d.pseudos.empty(a)},header:function(a){return X.test(a.nodeName)},input:function(a){return W.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||"text"===b.toLowerCase())},first:pa(function(){return[0]}),last:pa(function(a,b){return[b-1]}),eq:pa(function(a,b,c){return[c<0?c+b:c]}),even:pa(function(a,b){for(var c=0;c=0;)a.push(d);return a}),gt:pa(function(a,b,c){for(var d=c<0?c+b:c;++d1?function(b,c,d){var e=a.length;while(e--)if(!a[e](b,c,d))return!1;return!0}:a[0]}function va(a,b,c){for(var d=0,e=b.length;d-1&&(f[j]=!(g[j]=l))}}else r=wa(r===g?r.splice(o,r.length):r),e?e(null,g,r,i):G.apply(g,r)})}function ya(a){for(var b,c,e,f=a.length,g=d.relative[a[0].type],h=g||d.relative[" "],i=g?1:0,k=ta(function(a){return a===b},h,!0),l=ta(function(a){return I(b,a)>-1},h,!0),m=[function(a,c,d){var e=!g&&(d||c!==j)||((b=c).nodeType?k(a,c,d):l(a,c,d));return b=null,e}];i1&&ua(m),i>1&&sa(a.slice(0,i-1).concat({value:" "===a[i-2].type?"*":""})).replace(P,"$1"),c,i0,e=a.length>0,f=function(f,g,h,i,k){var l,o,q,r=0,s="0",t=f&&[],u=[],v=j,x=f||e&&d.find.TAG("*",k),y=w+=null==v?1:Math.random()||.1,z=x.length;for(k&&(j=g===n||g||k);s!==z&&null!=(l=x[s]);s++){if(e&&l){o=0,g||l.ownerDocument===n||(m(l),h=!p);while(q=a[o++])if(q(l,g||n,h)){i.push(l);break}k&&(w=y)}c&&((l=!q&&l)&&r--,f&&t.push(l))}if(r+=s,c&&s!==r){o=0;while(q=b[o++])q(t,u,g,h);if(f){if(r>0)while(s--)t[s]||u[s]||(u[s]=E.call(i));u=wa(u)}G.apply(i,u),k&&!f&&u.length>0&&r+b.length>1&&ga.uniqueSort(i)}return k&&(w=y,j=v),t};return c?ia(f):f}return h=ga.compile=function(a,b){var c,d=[],e=[],f=A[a+" "];if(!f){b||(b=g(a)),c=b.length;while(c--)f=ya(b[c]),f[u]?d.push(f):e.push(f);f=A(a,za(e,d)),f.selector=a}return f},i=ga.select=function(a,b,c,e){var f,i,j,k,l,m="function"==typeof a&&a,n=!e&&g(a=m.selector||a);if(c=c||[],1===n.length){if(i=n[0]=n[0].slice(0),i.length>2&&"ID"===(j=i[0]).type&&9===b.nodeType&&p&&d.relative[i[1].type]){if(b=(d.find.ID(j.matches[0].replace(_,aa),b)||[])[0],!b)return c;m&&(b=b.parentNode),a=a.slice(i.shift().value.length)}f=V.needsContext.test(a)?0:i.length;while(f--){if(j=i[f],d.relative[k=j.type])break;if((l=d.find[k])&&(e=l(j.matches[0].replace(_,aa),$.test(i[0].type)&&qa(b.parentNode)||b))){if(i.splice(f,1),a=e.length&&sa(i),!a)return G.apply(c,e),c;break}}}return(m||h(a,n))(e,b,!p,c,!b||$.test(a)&&qa(b.parentNode)||b),c},c.sortStable=u.split("").sort(B).join("")===u,c.detectDuplicates=!!l,m(),c.sortDetached=ja(function(a){return 1&a.compareDocumentPosition(n.createElement("fieldset"))}),ja(function(a){return a.innerHTML="","#"===a.firstChild.getAttribute("href")})||ka("type|href|height|width",function(a,b,c){if(!c)return a.getAttribute(b,"type"===b.toLowerCase()?1:2)}),c.attributes&&ja(function(a){return a.innerHTML="",a.firstChild.setAttribute("value",""),""===a.firstChild.getAttribute("value")})||ka("value",function(a,b,c){if(!c&&"input"===a.nodeName.toLowerCase())return a.defaultValue}),ja(function(a){return null==a.getAttribute("disabled")})||ka(J,function(a,b,c){var d;if(!c)return a[b]===!0?b.toLowerCase():(d=a.getAttributeNode(b))&&d.specified?d.value:null}),ga}(a);r.find=x,r.expr=x.selectors,r.expr[":"]=r.expr.pseudos,r.uniqueSort=r.unique=x.uniqueSort,r.text=x.getText,r.isXMLDoc=x.isXML,r.contains=x.contains,r.escapeSelector=x.escape;var y=function(a,b,c){var d=[],e=void 0!==c;while((a=a[b])&&9!==a.nodeType)if(1===a.nodeType){if(e&&r(a).is(c))break;d.push(a)}return d},z=function(a,b){for(var c=[];a;a=a.nextSibling)1===a.nodeType&&a!==b&&c.push(a);return c},A=r.expr.match.needsContext;function B(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()}var C=/^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i,D=/^.[^:#\[\.,]*$/;function E(a,b,c){return r.isFunction(b)?r.grep(a,function(a,d){return!!b.call(a,d,a)!==c}):b.nodeType?r.grep(a,function(a){return a===b!==c}):"string"!=typeof b?r.grep(a,function(a){return i.call(b,a)>-1!==c}):D.test(b)?r.filter(b,a,c):(b=r.filter(b,a),r.grep(a,function(a){return i.call(b,a)>-1!==c&&1===a.nodeType}))}r.filter=function(a,b,c){var d=b[0];return c&&(a=":not("+a+")"),1===b.length&&1===d.nodeType?r.find.matchesSelector(d,a)?[d]:[]:r.find.matches(a,r.grep(b,function(a){return 1===a.nodeType}))},r.fn.extend({find:function(a){var b,c,d=this.length,e=this;if("string"!=typeof a)return this.pushStack(r(a).filter(function(){for(b=0;b1?r.uniqueSort(c):c},filter:function(a){return this.pushStack(E(this,a||[],!1))},not:function(a){return this.pushStack(E(this,a||[],!0))},is:function(a){return!!E(this,"string"==typeof a&&A.test(a)?r(a):a||[],!1).length}});var F,G=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,H=r.fn.init=function(a,b,c){var e,f;if(!a)return this;if(c=c||F,"string"==typeof a){if(e="<"===a[0]&&">"===a[a.length-1]&&a.length>=3?[null,a,null]:G.exec(a),!e||!e[1]&&b)return!b||b.jquery?(b||c).find(a):this.constructor(b).find(a);if(e[1]){if(b=b instanceof r?b[0]:b,r.merge(this,r.parseHTML(e[1],b&&b.nodeType?b.ownerDocument||b:d,!0)),C.test(e[1])&&r.isPlainObject(b))for(e in b)r.isFunction(this[e])?this[e](b[e]):this.attr(e,b[e]);return this}return f=d.getElementById(e[2]),f&&(this[0]=f,this.length=1),this}return a.nodeType?(this[0]=a,this.length=1,this):r.isFunction(a)?void 0!==c.ready?c.ready(a):a(r):r.makeArray(a,this)};H.prototype=r.fn,F=r(d);var I=/^(?:parents|prev(?:Until|All))/,J={children:!0,contents:!0,next:!0,prev:!0};r.fn.extend({has:function(a){var b=r(a,this),c=b.length;return this.filter(function(){for(var a=0;a-1:1===c.nodeType&&r.find.matchesSelector(c,a))){f.push(c);break}return this.pushStack(f.length>1?r.uniqueSort(f):f)},index:function(a){return a?"string"==typeof a?i.call(r(a),this[0]):i.call(this,a.jquery?a[0]:a):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,b){return this.pushStack(r.uniqueSort(r.merge(this.get(),r(a,b))))},addBack:function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}});function K(a,b){while((a=a[b])&&1!==a.nodeType);return a}r.each({parent:function(a){var b=a.parentNode;return b&&11!==b.nodeType?b:null},parents:function(a){return y(a,"parentNode")},parentsUntil:function(a,b,c){return y(a,"parentNode",c)},next:function(a){return K(a,"nextSibling")},prev:function(a){return K(a,"previousSibling")},nextAll:function(a){return y(a,"nextSibling")},prevAll:function(a){return y(a,"previousSibling")},nextUntil:function(a,b,c){return y(a,"nextSibling",c)},prevUntil:function(a,b,c){return y(a,"previousSibling",c)},siblings:function(a){return z((a.parentNode||{}).firstChild,a)},children:function(a){return z(a.firstChild)},contents:function(a){return B(a,"iframe")?a.contentDocument:(B(a,"template")&&(a=a.content||a),r.merge([],a.childNodes))}},function(a,b){r.fn[a]=function(c,d){var e=r.map(this,b,c);return"Until"!==a.slice(-5)&&(d=c),d&&"string"==typeof d&&(e=r.filter(d,e)),this.length>1&&(J[a]||r.uniqueSort(e),I.test(a)&&e.reverse()),this.pushStack(e)}});var L=/[^\x20\t\r\n\f]+/g;function M(a){var b={};return r.each(a.match(L)||[],function(a,c){b[c]=!0}),b}r.Callbacks=function(a){a="string"==typeof a?M(a):r.extend({},a);var b,c,d,e,f=[],g=[],h=-1,i=function(){for(e=e||a.once,d=b=!0;g.length;h=-1){c=g.shift();while(++h-1)f.splice(c,1),c<=h&&h--}),this},has:function(a){return a?r.inArray(a,f)>-1:f.length>0},empty:function(){return f&&(f=[]),this},disable:function(){return e=g=[],f=c="",this},disabled:function(){return!f},lock:function(){return e=g=[],c||b||(f=c=""),this},locked:function(){return!!e},fireWith:function(a,c){return e||(c=c||[],c=[a,c.slice?c.slice():c],g.push(c),b||i()),this},fire:function(){return j.fireWith(this,arguments),this},fired:function(){return!!d}};return j};function N(a){return a}function O(a){throw a}function P(a,b,c,d){var e;try{a&&r.isFunction(e=a.promise)?e.call(a).done(b).fail(c):a&&r.isFunction(e=a.then)?e.call(a,b,c):b.apply(void 0,[a].slice(d))}catch(a){c.apply(void 0,[a])}}r.extend({Deferred:function(b){var c=[["notify","progress",r.Callbacks("memory"),r.Callbacks("memory"),2],["resolve","done",r.Callbacks("once memory"),r.Callbacks("once memory"),0,"resolved"],["reject","fail",r.Callbacks("once memory"),r.Callbacks("once memory"),1,"rejected"]],d="pending",e={state:function(){return d},always:function(){return f.done(arguments).fail(arguments),this},"catch":function(a){return e.then(null,a)},pipe:function(){var a=arguments;return r.Deferred(function(b){r.each(c,function(c,d){var e=r.isFunction(a[d[4]])&&a[d[4]];f[d[1]](function(){var a=e&&e.apply(this,arguments);a&&r.isFunction(a.promise)?a.promise().progress(b.notify).done(b.resolve).fail(b.reject):b[d[0]+"With"](this,e?[a]:arguments)})}),a=null}).promise()},then:function(b,d,e){var f=0;function g(b,c,d,e){return function(){var h=this,i=arguments,j=function(){var a,j;if(!(b=f&&(d!==O&&(h=void 0,i=[a]),c.rejectWith(h,i))}};b?k():(r.Deferred.getStackHook&&(k.stackTrace=r.Deferred.getStackHook()),a.setTimeout(k))}}return r.Deferred(function(a){c[0][3].add(g(0,a,r.isFunction(e)?e:N,a.notifyWith)),c[1][3].add(g(0,a,r.isFunction(b)?b:N)),c[2][3].add(g(0,a,r.isFunction(d)?d:O))}).promise()},promise:function(a){return null!=a?r.extend(a,e):e}},f={};return r.each(c,function(a,b){var g=b[2],h=b[5];e[b[1]]=g.add,h&&g.add(function(){d=h},c[3-a][2].disable,c[0][2].lock),g.add(b[3].fire),f[b[0]]=function(){return f[b[0]+"With"](this===f?void 0:this,arguments),this},f[b[0]+"With"]=g.fireWith}),e.promise(f),b&&b.call(f,f),f},when:function(a){var b=arguments.length,c=b,d=Array(c),e=f.call(arguments),g=r.Deferred(),h=function(a){return function(c){d[a]=this,e[a]=arguments.length>1?f.call(arguments):c,--b||g.resolveWith(d,e)}};if(b<=1&&(P(a,g.done(h(c)).resolve,g.reject,!b),"pending"===g.state()||r.isFunction(e[c]&&e[c].then)))return g.then();while(c--)P(e[c],h(c),g.reject);return g.promise()}});var Q=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;r.Deferred.exceptionHook=function(b,c){a.console&&a.console.warn&&b&&Q.test(b.name)&&a.console.warn("jQuery.Deferred exception: "+b.message,b.stack,c)},r.readyException=function(b){a.setTimeout(function(){throw b})};var R=r.Deferred();r.fn.ready=function(a){return R.then(a)["catch"](function(a){r.readyException(a)}),this},r.extend({isReady:!1,readyWait:1,ready:function(a){(a===!0?--r.readyWait:r.isReady)||(r.isReady=!0,a!==!0&&--r.readyWait>0||R.resolveWith(d,[r]))}}),r.ready.then=R.then;function S(){d.removeEventListener("DOMContentLoaded",S), -a.removeEventListener("load",S),r.ready()}"complete"===d.readyState||"loading"!==d.readyState&&!d.documentElement.doScroll?a.setTimeout(r.ready):(d.addEventListener("DOMContentLoaded",S),a.addEventListener("load",S));var T=function(a,b,c,d,e,f,g){var h=0,i=a.length,j=null==c;if("object"===r.type(c)){e=!0;for(h in c)T(a,b,h,c[h],!0,f,g)}else if(void 0!==d&&(e=!0,r.isFunction(d)||(g=!0),j&&(g?(b.call(a,d),b=null):(j=b,b=function(a,b,c){return j.call(r(a),c)})),b))for(;h1,null,!0)},removeData:function(a){return this.each(function(){X.remove(this,a)})}}),r.extend({queue:function(a,b,c){var d;if(a)return b=(b||"fx")+"queue",d=W.get(a,b),c&&(!d||Array.isArray(c)?d=W.access(a,b,r.makeArray(c)):d.push(c)),d||[]},dequeue:function(a,b){b=b||"fx";var c=r.queue(a,b),d=c.length,e=c.shift(),f=r._queueHooks(a,b),g=function(){r.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return W.get(a,c)||W.access(a,c,{empty:r.Callbacks("once memory").add(function(){W.remove(a,[b+"queue",c])})})}}),r.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.length\x20\t\r\n\f]+)/i,la=/^$|\/(?:java|ecma)script/i,ma={option:[1,""],thead:[1,"","
"],col:[2,"","
"],tr:[2,"","
"],td:[3,"","
"],_default:[0,"",""]};ma.optgroup=ma.option,ma.tbody=ma.tfoot=ma.colgroup=ma.caption=ma.thead,ma.th=ma.td;function na(a,b){var c;return c="undefined"!=typeof a.getElementsByTagName?a.getElementsByTagName(b||"*"):"undefined"!=typeof a.querySelectorAll?a.querySelectorAll(b||"*"):[],void 0===b||b&&B(a,b)?r.merge([a],c):c}function oa(a,b){for(var c=0,d=a.length;c-1)e&&e.push(f);else if(j=r.contains(f.ownerDocument,f),g=na(l.appendChild(f),"script"),j&&oa(g),c){k=0;while(f=g[k++])la.test(f.type||"")&&c.push(f)}return l}!function(){var a=d.createDocumentFragment(),b=a.appendChild(d.createElement("div")),c=d.createElement("input");c.setAttribute("type","radio"),c.setAttribute("checked","checked"),c.setAttribute("name","t"),b.appendChild(c),o.checkClone=b.cloneNode(!0).cloneNode(!0).lastChild.checked,b.innerHTML="",o.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue}();var ra=d.documentElement,sa=/^key/,ta=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,ua=/^([^.]*)(?:\.(.+)|)/;function va(){return!0}function wa(){return!1}function xa(){try{return d.activeElement}catch(a){}}function ya(a,b,c,d,e,f){var g,h;if("object"==typeof b){"string"!=typeof c&&(d=d||c,c=void 0);for(h in b)ya(a,h,c,d,b[h],f);return a}if(null==d&&null==e?(e=c,d=c=void 0):null==e&&("string"==typeof c?(e=d,d=void 0):(e=d,d=c,c=void 0)),e===!1)e=wa;else if(!e)return a;return 1===f&&(g=e,e=function(a){return r().off(a),g.apply(this,arguments)},e.guid=g.guid||(g.guid=r.guid++)),a.each(function(){r.event.add(this,b,e,d,c)})}r.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,n,o,p,q=W.get(a);if(q){c.handler&&(f=c,c=f.handler,e=f.selector),e&&r.find.matchesSelector(ra,e),c.guid||(c.guid=r.guid++),(i=q.events)||(i=q.events={}),(g=q.handle)||(g=q.handle=function(b){return"undefined"!=typeof r&&r.event.triggered!==b.type?r.event.dispatch.apply(a,arguments):void 0}),b=(b||"").match(L)||[""],j=b.length;while(j--)h=ua.exec(b[j])||[],n=p=h[1],o=(h[2]||"").split(".").sort(),n&&(l=r.event.special[n]||{},n=(e?l.delegateType:l.bindType)||n,l=r.event.special[n]||{},k=r.extend({type:n,origType:p,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&r.expr.match.needsContext.test(e),namespace:o.join(".")},f),(m=i[n])||(m=i[n]=[],m.delegateCount=0,l.setup&&l.setup.call(a,d,o,g)!==!1||a.addEventListener&&a.addEventListener(n,g)),l.add&&(l.add.call(a,k),k.handler.guid||(k.handler.guid=c.guid)),e?m.splice(m.delegateCount++,0,k):m.push(k),r.event.global[n]=!0)}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,n,o,p,q=W.hasData(a)&&W.get(a);if(q&&(i=q.events)){b=(b||"").match(L)||[""],j=b.length;while(j--)if(h=ua.exec(b[j])||[],n=p=h[1],o=(h[2]||"").split(".").sort(),n){l=r.event.special[n]||{},n=(d?l.delegateType:l.bindType)||n,m=i[n]||[],h=h[2]&&new RegExp("(^|\\.)"+o.join("\\.(?:.*\\.|)")+"(\\.|$)"),g=f=m.length;while(f--)k=m[f],!e&&p!==k.origType||c&&c.guid!==k.guid||h&&!h.test(k.namespace)||d&&d!==k.selector&&("**"!==d||!k.selector)||(m.splice(f,1),k.selector&&m.delegateCount--,l.remove&&l.remove.call(a,k));g&&!m.length&&(l.teardown&&l.teardown.call(a,o,q.handle)!==!1||r.removeEvent(a,n,q.handle),delete i[n])}else for(n in i)r.event.remove(a,n+b[j],c,d,!0);r.isEmptyObject(i)&&W.remove(a,"handle events")}},dispatch:function(a){var b=r.event.fix(a),c,d,e,f,g,h,i=new Array(arguments.length),j=(W.get(this,"events")||{})[b.type]||[],k=r.event.special[b.type]||{};for(i[0]=b,c=1;c=1))for(;j!==this;j=j.parentNode||this)if(1===j.nodeType&&("click"!==a.type||j.disabled!==!0)){for(f=[],g={},c=0;c-1:r.find(e,this,null,[j]).length),g[e]&&f.push(d);f.length&&h.push({elem:j,handlers:f})}return j=this,i\x20\t\r\n\f]*)[^>]*)\/>/gi,Aa=/\s*$/g;function Ea(a,b){return B(a,"table")&&B(11!==b.nodeType?b:b.firstChild,"tr")?r(">tbody",a)[0]||a:a}function Fa(a){return a.type=(null!==a.getAttribute("type"))+"/"+a.type,a}function Ga(a){var b=Ca.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function Ha(a,b){var c,d,e,f,g,h,i,j;if(1===b.nodeType){if(W.hasData(a)&&(f=W.access(a),g=W.set(b,f),j=f.events)){delete g.handle,g.events={};for(e in j)for(c=0,d=j[e].length;c1&&"string"==typeof q&&!o.checkClone&&Ba.test(q))return a.each(function(e){var f=a.eq(e);s&&(b[0]=q.call(this,e,f.html())),Ja(f,b,c,d)});if(m&&(e=qa(b,a[0].ownerDocument,!1,a,d),f=e.firstChild,1===e.childNodes.length&&(e=f),f||d)){for(h=r.map(na(e,"script"),Fa),i=h.length;l")},clone:function(a,b,c){var d,e,f,g,h=a.cloneNode(!0),i=r.contains(a.ownerDocument,a);if(!(o.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||r.isXMLDoc(a)))for(g=na(h),f=na(a),d=0,e=f.length;d0&&oa(g,!i&&na(a,"script")),h},cleanData:function(a){for(var b,c,d,e=r.event.special,f=0;void 0!==(c=a[f]);f++)if(U(c)){if(b=c[W.expando]){if(b.events)for(d in b.events)e[d]?r.event.remove(c,d):r.removeEvent(c,d,b.handle);c[W.expando]=void 0}c[X.expando]&&(c[X.expando]=void 0)}}}),r.fn.extend({detach:function(a){return Ka(this,a,!0)},remove:function(a){return Ka(this,a)},text:function(a){return T(this,function(a){return void 0===a?r.text(this):this.empty().each(function(){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||(this.textContent=a)})},null,a,arguments.length)},append:function(){return Ja(this,arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=Ea(this,a);b.appendChild(a)}})},prepend:function(){return Ja(this,arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=Ea(this,a);b.insertBefore(a,b.firstChild)}})},before:function(){return Ja(this,arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return Ja(this,arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},empty:function(){for(var a,b=0;null!=(a=this[b]);b++)1===a.nodeType&&(r.cleanData(na(a,!1)),a.textContent="");return this},clone:function(a,b){return a=null!=a&&a,b=null==b?a:b,this.map(function(){return r.clone(this,a,b)})},html:function(a){return T(this,function(a){var b=this[0]||{},c=0,d=this.length;if(void 0===a&&1===b.nodeType)return b.innerHTML;if("string"==typeof a&&!Aa.test(a)&&!ma[(ka.exec(a)||["",""])[1].toLowerCase()]){a=r.htmlPrefilter(a);try{for(;c1)}});function _a(a,b,c,d,e){return new _a.prototype.init(a,b,c,d,e)}r.Tween=_a,_a.prototype={constructor:_a,init:function(a,b,c,d,e,f){this.elem=a,this.prop=c,this.easing=e||r.easing._default,this.options=b,this.start=this.now=this.cur(),this.end=d,this.unit=f||(r.cssNumber[c]?"":"px")},cur:function(){var a=_a.propHooks[this.prop];return a&&a.get?a.get(this):_a.propHooks._default.get(this)},run:function(a){var b,c=_a.propHooks[this.prop];return this.options.duration?this.pos=b=r.easing[this.easing](a,this.options.duration*a,0,1,this.options.duration):this.pos=b=a,this.now=(this.end-this.start)*b+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),c&&c.set?c.set(this):_a.propHooks._default.set(this),this}},_a.prototype.init.prototype=_a.prototype,_a.propHooks={_default:{get:function(a){var b;return 1!==a.elem.nodeType||null!=a.elem[a.prop]&&null==a.elem.style[a.prop]?a.elem[a.prop]:(b=r.css(a.elem,a.prop,""),b&&"auto"!==b?b:0)},set:function(a){r.fx.step[a.prop]?r.fx.step[a.prop](a):1!==a.elem.nodeType||null==a.elem.style[r.cssProps[a.prop]]&&!r.cssHooks[a.prop]?a.elem[a.prop]=a.now:r.style(a.elem,a.prop,a.now+a.unit)}}},_a.propHooks.scrollTop=_a.propHooks.scrollLeft={set:function(a){a.elem.nodeType&&a.elem.parentNode&&(a.elem[a.prop]=a.now)}},r.easing={linear:function(a){return a},swing:function(a){return.5-Math.cos(a*Math.PI)/2},_default:"swing"},r.fx=_a.prototype.init,r.fx.step={};var ab,bb,cb=/^(?:toggle|show|hide)$/,db=/queueHooks$/;function eb(){bb&&(d.hidden===!1&&a.requestAnimationFrame?a.requestAnimationFrame(eb):a.setTimeout(eb,r.fx.interval),r.fx.tick())}function fb(){return a.setTimeout(function(){ab=void 0}),ab=r.now()}function gb(a,b){var c,d=0,e={height:a};for(b=b?1:0;d<4;d+=2-b)c=ca[d],e["margin"+c]=e["padding"+c]=a;return b&&(e.opacity=e.width=a),e}function hb(a,b,c){for(var d,e=(kb.tweeners[b]||[]).concat(kb.tweeners["*"]),f=0,g=e.length;f1)},removeAttr:function(a){return this.each(function(){r.removeAttr(this,a)})}}),r.extend({attr:function(a,b,c){var d,e,f=a.nodeType;if(3!==f&&8!==f&&2!==f)return"undefined"==typeof a.getAttribute?r.prop(a,b,c):(1===f&&r.isXMLDoc(a)||(e=r.attrHooks[b.toLowerCase()]||(r.expr.match.bool.test(b)?lb:void 0)),void 0!==c?null===c?void r.removeAttr(a,b):e&&"set"in e&&void 0!==(d=e.set(a,c,b))?d:(a.setAttribute(b,c+""),c):e&&"get"in e&&null!==(d=e.get(a,b))?d:(d=r.find.attr(a,b), -null==d?void 0:d))},attrHooks:{type:{set:function(a,b){if(!o.radioValue&&"radio"===b&&B(a,"input")){var c=a.value;return a.setAttribute("type",b),c&&(a.value=c),b}}}},removeAttr:function(a,b){var c,d=0,e=b&&b.match(L);if(e&&1===a.nodeType)while(c=e[d++])a.removeAttribute(c)}}),lb={set:function(a,b,c){return b===!1?r.removeAttr(a,c):a.setAttribute(c,c),c}},r.each(r.expr.match.bool.source.match(/\w+/g),function(a,b){var c=mb[b]||r.find.attr;mb[b]=function(a,b,d){var e,f,g=b.toLowerCase();return d||(f=mb[g],mb[g]=e,e=null!=c(a,b,d)?g:null,mb[g]=f),e}});var nb=/^(?:input|select|textarea|button)$/i,ob=/^(?:a|area)$/i;r.fn.extend({prop:function(a,b){return T(this,r.prop,a,b,arguments.length>1)},removeProp:function(a){return this.each(function(){delete this[r.propFix[a]||a]})}}),r.extend({prop:function(a,b,c){var d,e,f=a.nodeType;if(3!==f&&8!==f&&2!==f)return 1===f&&r.isXMLDoc(a)||(b=r.propFix[b]||b,e=r.propHooks[b]),void 0!==c?e&&"set"in e&&void 0!==(d=e.set(a,c,b))?d:a[b]=c:e&&"get"in e&&null!==(d=e.get(a,b))?d:a[b]},propHooks:{tabIndex:{get:function(a){var b=r.find.attr(a,"tabindex");return b?parseInt(b,10):nb.test(a.nodeName)||ob.test(a.nodeName)&&a.href?0:-1}}},propFix:{"for":"htmlFor","class":"className"}}),o.optSelected||(r.propHooks.selected={get:function(a){var b=a.parentNode;return b&&b.parentNode&&b.parentNode.selectedIndex,null},set:function(a){var b=a.parentNode;b&&(b.selectedIndex,b.parentNode&&b.parentNode.selectedIndex)}}),r.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){r.propFix[this.toLowerCase()]=this});function pb(a){var b=a.match(L)||[];return b.join(" ")}function qb(a){return a.getAttribute&&a.getAttribute("class")||""}r.fn.extend({addClass:function(a){var b,c,d,e,f,g,h,i=0;if(r.isFunction(a))return this.each(function(b){r(this).addClass(a.call(this,b,qb(this)))});if("string"==typeof a&&a){b=a.match(L)||[];while(c=this[i++])if(e=qb(c),d=1===c.nodeType&&" "+pb(e)+" "){g=0;while(f=b[g++])d.indexOf(" "+f+" ")<0&&(d+=f+" ");h=pb(d),e!==h&&c.setAttribute("class",h)}}return this},removeClass:function(a){var b,c,d,e,f,g,h,i=0;if(r.isFunction(a))return this.each(function(b){r(this).removeClass(a.call(this,b,qb(this)))});if(!arguments.length)return this.attr("class","");if("string"==typeof a&&a){b=a.match(L)||[];while(c=this[i++])if(e=qb(c),d=1===c.nodeType&&" "+pb(e)+" "){g=0;while(f=b[g++])while(d.indexOf(" "+f+" ")>-1)d=d.replace(" "+f+" "," ");h=pb(d),e!==h&&c.setAttribute("class",h)}}return this},toggleClass:function(a,b){var c=typeof a;return"boolean"==typeof b&&"string"===c?b?this.addClass(a):this.removeClass(a):r.isFunction(a)?this.each(function(c){r(this).toggleClass(a.call(this,c,qb(this),b),b)}):this.each(function(){var b,d,e,f;if("string"===c){d=0,e=r(this),f=a.match(L)||[];while(b=f[d++])e.hasClass(b)?e.removeClass(b):e.addClass(b)}else void 0!==a&&"boolean"!==c||(b=qb(this),b&&W.set(this,"__className__",b),this.setAttribute&&this.setAttribute("class",b||a===!1?"":W.get(this,"__className__")||""))})},hasClass:function(a){var b,c,d=0;b=" "+a+" ";while(c=this[d++])if(1===c.nodeType&&(" "+pb(qb(c))+" ").indexOf(b)>-1)return!0;return!1}});var rb=/\r/g;r.fn.extend({val:function(a){var b,c,d,e=this[0];{if(arguments.length)return d=r.isFunction(a),this.each(function(c){var e;1===this.nodeType&&(e=d?a.call(this,c,r(this).val()):a,null==e?e="":"number"==typeof e?e+="":Array.isArray(e)&&(e=r.map(e,function(a){return null==a?"":a+""})),b=r.valHooks[this.type]||r.valHooks[this.nodeName.toLowerCase()],b&&"set"in b&&void 0!==b.set(this,e,"value")||(this.value=e))});if(e)return b=r.valHooks[e.type]||r.valHooks[e.nodeName.toLowerCase()],b&&"get"in b&&void 0!==(c=b.get(e,"value"))?c:(c=e.value,"string"==typeof c?c.replace(rb,""):null==c?"":c)}}}),r.extend({valHooks:{option:{get:function(a){var b=r.find.attr(a,"value");return null!=b?b:pb(r.text(a))}},select:{get:function(a){var b,c,d,e=a.options,f=a.selectedIndex,g="select-one"===a.type,h=g?null:[],i=g?f+1:e.length;for(d=f<0?i:g?f:0;d-1)&&(c=!0);return c||(a.selectedIndex=-1),f}}}}),r.each(["radio","checkbox"],function(){r.valHooks[this]={set:function(a,b){if(Array.isArray(b))return a.checked=r.inArray(r(a).val(),b)>-1}},o.checkOn||(r.valHooks[this].get=function(a){return null===a.getAttribute("value")?"on":a.value})});var sb=/^(?:focusinfocus|focusoutblur)$/;r.extend(r.event,{trigger:function(b,c,e,f){var g,h,i,j,k,m,n,o=[e||d],p=l.call(b,"type")?b.type:b,q=l.call(b,"namespace")?b.namespace.split("."):[];if(h=i=e=e||d,3!==e.nodeType&&8!==e.nodeType&&!sb.test(p+r.event.triggered)&&(p.indexOf(".")>-1&&(q=p.split("."),p=q.shift(),q.sort()),k=p.indexOf(":")<0&&"on"+p,b=b[r.expando]?b:new r.Event(p,"object"==typeof b&&b),b.isTrigger=f?2:3,b.namespace=q.join("."),b.rnamespace=b.namespace?new RegExp("(^|\\.)"+q.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,b.result=void 0,b.target||(b.target=e),c=null==c?[b]:r.makeArray(c,[b]),n=r.event.special[p]||{},f||!n.trigger||n.trigger.apply(e,c)!==!1)){if(!f&&!n.noBubble&&!r.isWindow(e)){for(j=n.delegateType||p,sb.test(j+p)||(h=h.parentNode);h;h=h.parentNode)o.push(h),i=h;i===(e.ownerDocument||d)&&o.push(i.defaultView||i.parentWindow||a)}g=0;while((h=o[g++])&&!b.isPropagationStopped())b.type=g>1?j:n.bindType||p,m=(W.get(h,"events")||{})[b.type]&&W.get(h,"handle"),m&&m.apply(h,c),m=k&&h[k],m&&m.apply&&U(h)&&(b.result=m.apply(h,c),b.result===!1&&b.preventDefault());return b.type=p,f||b.isDefaultPrevented()||n._default&&n._default.apply(o.pop(),c)!==!1||!U(e)||k&&r.isFunction(e[p])&&!r.isWindow(e)&&(i=e[k],i&&(e[k]=null),r.event.triggered=p,e[p](),r.event.triggered=void 0,i&&(e[k]=i)),b.result}},simulate:function(a,b,c){var d=r.extend(new r.Event,c,{type:a,isSimulated:!0});r.event.trigger(d,null,b)}}),r.fn.extend({trigger:function(a,b){return this.each(function(){r.event.trigger(a,b,this)})},triggerHandler:function(a,b){var c=this[0];if(c)return r.event.trigger(a,b,c,!0)}}),r.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(a,b){r.fn[b]=function(a,c){return arguments.length>0?this.on(b,null,a,c):this.trigger(b)}}),r.fn.extend({hover:function(a,b){return this.mouseenter(a).mouseleave(b||a)}}),o.focusin="onfocusin"in a,o.focusin||r.each({focus:"focusin",blur:"focusout"},function(a,b){var c=function(a){r.event.simulate(b,a.target,r.event.fix(a))};r.event.special[b]={setup:function(){var d=this.ownerDocument||this,e=W.access(d,b);e||d.addEventListener(a,c,!0),W.access(d,b,(e||0)+1)},teardown:function(){var d=this.ownerDocument||this,e=W.access(d,b)-1;e?W.access(d,b,e):(d.removeEventListener(a,c,!0),W.remove(d,b))}}});var tb=a.location,ub=r.now(),vb=/\?/;r.parseXML=function(b){var c;if(!b||"string"!=typeof b)return null;try{c=(new a.DOMParser).parseFromString(b,"text/xml")}catch(d){c=void 0}return c&&!c.getElementsByTagName("parsererror").length||r.error("Invalid XML: "+b),c};var wb=/\[\]$/,xb=/\r?\n/g,yb=/^(?:submit|button|image|reset|file)$/i,zb=/^(?:input|select|textarea|keygen)/i;function Ab(a,b,c,d){var e;if(Array.isArray(b))r.each(b,function(b,e){c||wb.test(a)?d(a,e):Ab(a+"["+("object"==typeof e&&null!=e?b:"")+"]",e,c,d)});else if(c||"object"!==r.type(b))d(a,b);else for(e in b)Ab(a+"["+e+"]",b[e],c,d)}r.param=function(a,b){var c,d=[],e=function(a,b){var c=r.isFunction(b)?b():b;d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(null==c?"":c)};if(Array.isArray(a)||a.jquery&&!r.isPlainObject(a))r.each(a,function(){e(this.name,this.value)});else for(c in a)Ab(c,a[c],b,e);return d.join("&")},r.fn.extend({serialize:function(){return r.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var a=r.prop(this,"elements");return a?r.makeArray(a):this}).filter(function(){var a=this.type;return this.name&&!r(this).is(":disabled")&&zb.test(this.nodeName)&&!yb.test(a)&&(this.checked||!ja.test(a))}).map(function(a,b){var c=r(this).val();return null==c?null:Array.isArray(c)?r.map(c,function(a){return{name:b.name,value:a.replace(xb,"\r\n")}}):{name:b.name,value:c.replace(xb,"\r\n")}}).get()}});var Bb=/%20/g,Cb=/#.*$/,Db=/([?&])_=[^&]*/,Eb=/^(.*?):[ \t]*([^\r\n]*)$/gm,Fb=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Gb=/^(?:GET|HEAD)$/,Hb=/^\/\//,Ib={},Jb={},Kb="*/".concat("*"),Lb=d.createElement("a");Lb.href=tb.href;function Mb(a){return function(b,c){"string"!=typeof b&&(c=b,b="*");var d,e=0,f=b.toLowerCase().match(L)||[];if(r.isFunction(c))while(d=f[e++])"+"===d[0]?(d=d.slice(1)||"*",(a[d]=a[d]||[]).unshift(c)):(a[d]=a[d]||[]).push(c)}}function Nb(a,b,c,d){var e={},f=a===Jb;function g(h){var i;return e[h]=!0,r.each(a[h]||[],function(a,h){var j=h(b,c,d);return"string"!=typeof j||f||e[j]?f?!(i=j):void 0:(b.dataTypes.unshift(j),g(j),!1)}),i}return g(b.dataTypes[0])||!e["*"]&&g("*")}function Ob(a,b){var c,d,e=r.ajaxSettings.flatOptions||{};for(c in b)void 0!==b[c]&&((e[c]?a:d||(d={}))[c]=b[c]);return d&&r.extend(!0,a,d),a}function Pb(a,b,c){var d,e,f,g,h=a.contents,i=a.dataTypes;while("*"===i[0])i.shift(),void 0===d&&(d=a.mimeType||b.getResponseHeader("Content-Type"));if(d)for(e in h)if(h[e]&&h[e].test(d)){i.unshift(e);break}if(i[0]in c)f=i[0];else{for(e in c){if(!i[0]||a.converters[e+" "+i[0]]){f=e;break}g||(g=e)}f=f||g}if(f)return f!==i[0]&&i.unshift(f),c[f]}function Qb(a,b,c,d){var e,f,g,h,i,j={},k=a.dataTypes.slice();if(k[1])for(g in a.converters)j[g.toLowerCase()]=a.converters[g];f=k.shift();while(f)if(a.responseFields[f]&&(c[a.responseFields[f]]=b),!i&&d&&a.dataFilter&&(b=a.dataFilter(b,a.dataType)),i=f,f=k.shift())if("*"===f)f=i;else if("*"!==i&&i!==f){if(g=j[i+" "+f]||j["* "+f],!g)for(e in j)if(h=e.split(" "),h[1]===f&&(g=j[i+" "+h[0]]||j["* "+h[0]])){g===!0?g=j[e]:j[e]!==!0&&(f=h[0],k.unshift(h[1]));break}if(g!==!0)if(g&&a["throws"])b=g(b);else try{b=g(b)}catch(l){return{state:"parsererror",error:g?l:"No conversion from "+i+" to "+f}}}return{state:"success",data:b}}r.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:tb.href,type:"GET",isLocal:Fb.test(tb.protocol),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Kb,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/\bxml\b/,html:/\bhtml/,json:/\bjson\b/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":JSON.parse,"text xml":r.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(a,b){return b?Ob(Ob(a,r.ajaxSettings),b):Ob(r.ajaxSettings,a)},ajaxPrefilter:Mb(Ib),ajaxTransport:Mb(Jb),ajax:function(b,c){"object"==typeof b&&(c=b,b=void 0),c=c||{};var e,f,g,h,i,j,k,l,m,n,o=r.ajaxSetup({},c),p=o.context||o,q=o.context&&(p.nodeType||p.jquery)?r(p):r.event,s=r.Deferred(),t=r.Callbacks("once memory"),u=o.statusCode||{},v={},w={},x="canceled",y={readyState:0,getResponseHeader:function(a){var b;if(k){if(!h){h={};while(b=Eb.exec(g))h[b[1].toLowerCase()]=b[2]}b=h[a.toLowerCase()]}return null==b?null:b},getAllResponseHeaders:function(){return k?g:null},setRequestHeader:function(a,b){return null==k&&(a=w[a.toLowerCase()]=w[a.toLowerCase()]||a,v[a]=b),this},overrideMimeType:function(a){return null==k&&(o.mimeType=a),this},statusCode:function(a){var b;if(a)if(k)y.always(a[y.status]);else for(b in a)u[b]=[u[b],a[b]];return this},abort:function(a){var b=a||x;return e&&e.abort(b),A(0,b),this}};if(s.promise(y),o.url=((b||o.url||tb.href)+"").replace(Hb,tb.protocol+"//"),o.type=c.method||c.type||o.method||o.type,o.dataTypes=(o.dataType||"*").toLowerCase().match(L)||[""],null==o.crossDomain){j=d.createElement("a");try{j.href=o.url,j.href=j.href,o.crossDomain=Lb.protocol+"//"+Lb.host!=j.protocol+"//"+j.host}catch(z){o.crossDomain=!0}}if(o.data&&o.processData&&"string"!=typeof o.data&&(o.data=r.param(o.data,o.traditional)),Nb(Ib,o,c,y),k)return y;l=r.event&&o.global,l&&0===r.active++&&r.event.trigger("ajaxStart"),o.type=o.type.toUpperCase(),o.hasContent=!Gb.test(o.type),f=o.url.replace(Cb,""),o.hasContent?o.data&&o.processData&&0===(o.contentType||"").indexOf("application/x-www-form-urlencoded")&&(o.data=o.data.replace(Bb,"+")):(n=o.url.slice(f.length),o.data&&(f+=(vb.test(f)?"&":"?")+o.data,delete o.data),o.cache===!1&&(f=f.replace(Db,"$1"),n=(vb.test(f)?"&":"?")+"_="+ub++ +n),o.url=f+n),o.ifModified&&(r.lastModified[f]&&y.setRequestHeader("If-Modified-Since",r.lastModified[f]),r.etag[f]&&y.setRequestHeader("If-None-Match",r.etag[f])),(o.data&&o.hasContent&&o.contentType!==!1||c.contentType)&&y.setRequestHeader("Content-Type",o.contentType),y.setRequestHeader("Accept",o.dataTypes[0]&&o.accepts[o.dataTypes[0]]?o.accepts[o.dataTypes[0]]+("*"!==o.dataTypes[0]?", "+Kb+"; q=0.01":""):o.accepts["*"]);for(m in o.headers)y.setRequestHeader(m,o.headers[m]);if(o.beforeSend&&(o.beforeSend.call(p,y,o)===!1||k))return y.abort();if(x="abort",t.add(o.complete),y.done(o.success),y.fail(o.error),e=Nb(Jb,o,c,y)){if(y.readyState=1,l&&q.trigger("ajaxSend",[y,o]),k)return y;o.async&&o.timeout>0&&(i=a.setTimeout(function(){y.abort("timeout")},o.timeout));try{k=!1,e.send(v,A)}catch(z){if(k)throw z;A(-1,z)}}else A(-1,"No Transport");function A(b,c,d,h){var j,m,n,v,w,x=c;k||(k=!0,i&&a.clearTimeout(i),e=void 0,g=h||"",y.readyState=b>0?4:0,j=b>=200&&b<300||304===b,d&&(v=Pb(o,y,d)),v=Qb(o,v,y,j),j?(o.ifModified&&(w=y.getResponseHeader("Last-Modified"),w&&(r.lastModified[f]=w),w=y.getResponseHeader("etag"),w&&(r.etag[f]=w)),204===b||"HEAD"===o.type?x="nocontent":304===b?x="notmodified":(x=v.state,m=v.data,n=v.error,j=!n)):(n=x,!b&&x||(x="error",b<0&&(b=0))),y.status=b,y.statusText=(c||x)+"",j?s.resolveWith(p,[m,x,y]):s.rejectWith(p,[y,x,n]),y.statusCode(u),u=void 0,l&&q.trigger(j?"ajaxSuccess":"ajaxError",[y,o,j?m:n]),t.fireWith(p,[y,x]),l&&(q.trigger("ajaxComplete",[y,o]),--r.active||r.event.trigger("ajaxStop")))}return y},getJSON:function(a,b,c){return r.get(a,b,c,"json")},getScript:function(a,b){return r.get(a,void 0,b,"script")}}),r.each(["get","post"],function(a,b){r[b]=function(a,c,d,e){return r.isFunction(c)&&(e=e||d,d=c,c=void 0),r.ajax(r.extend({url:a,type:b,dataType:e,data:c,success:d},r.isPlainObject(a)&&a))}}),r._evalUrl=function(a){return r.ajax({url:a,type:"GET",dataType:"script",cache:!0,async:!1,global:!1,"throws":!0})},r.fn.extend({wrapAll:function(a){var b;return this[0]&&(r.isFunction(a)&&(a=a.call(this[0])),b=r(a,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstElementChild)a=a.firstElementChild;return a}).append(this)),this},wrapInner:function(a){return r.isFunction(a)?this.each(function(b){r(this).wrapInner(a.call(this,b))}):this.each(function(){var b=r(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=r.isFunction(a);return this.each(function(c){r(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(a){return this.parent(a).not("body").each(function(){r(this).replaceWith(this.childNodes)}),this}}),r.expr.pseudos.hidden=function(a){return!r.expr.pseudos.visible(a)},r.expr.pseudos.visible=function(a){return!!(a.offsetWidth||a.offsetHeight||a.getClientRects().length)},r.ajaxSettings.xhr=function(){try{return new a.XMLHttpRequest}catch(b){}};var Rb={0:200,1223:204},Sb=r.ajaxSettings.xhr();o.cors=!!Sb&&"withCredentials"in Sb,o.ajax=Sb=!!Sb,r.ajaxTransport(function(b){var c,d;if(o.cors||Sb&&!b.crossDomain)return{send:function(e,f){var g,h=b.xhr();if(h.open(b.type,b.url,b.async,b.username,b.password),b.xhrFields)for(g in b.xhrFields)h[g]=b.xhrFields[g];b.mimeType&&h.overrideMimeType&&h.overrideMimeType(b.mimeType),b.crossDomain||e["X-Requested-With"]||(e["X-Requested-With"]="XMLHttpRequest");for(g in e)h.setRequestHeader(g,e[g]);c=function(a){return function(){c&&(c=d=h.onload=h.onerror=h.onabort=h.onreadystatechange=null,"abort"===a?h.abort():"error"===a?"number"!=typeof h.status?f(0,"error"):f(h.status,h.statusText):f(Rb[h.status]||h.status,h.statusText,"text"!==(h.responseType||"text")||"string"!=typeof h.responseText?{binary:h.response}:{text:h.responseText},h.getAllResponseHeaders()))}},h.onload=c(),d=h.onerror=c("error"),void 0!==h.onabort?h.onabort=d:h.onreadystatechange=function(){4===h.readyState&&a.setTimeout(function(){c&&d()})},c=c("abort");try{h.send(b.hasContent&&b.data||null)}catch(i){if(c)throw i}},abort:function(){c&&c()}}}),r.ajaxPrefilter(function(a){a.crossDomain&&(a.contents.script=!1)}),r.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/\b(?:java|ecma)script\b/},converters:{"text script":function(a){return r.globalEval(a),a}}}),r.ajaxPrefilter("script",function(a){void 0===a.cache&&(a.cache=!1),a.crossDomain&&(a.type="GET")}),r.ajaxTransport("script",function(a){if(a.crossDomain){var b,c;return{send:function(e,f){b=r("
Tree Tabs

+ +
@@ -38,6 +38,8 @@
+ +
@@ -54,6 +56,8 @@
+ +
@@ -73,10 +77,94 @@
+
    +
  • + + +
  • +
  • + + +
  • +
+ + +
+ +
    +
  • + + +
  • +
  • + + +
  • +
+ + + + + + +
-
+
+ + +
+
    +
  • + + +
  • +
  • + + +
  • +
@@ -88,68 +176,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
-
-
-
-
-
-
-
-
-
-
-
  • @@ -196,21 +223,86 @@ + + + + + + +
    -
- + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
-
-
-
-
-
-
-
-
-
+
+ + + + +
- - - - - - + + + + + +

@@ -240,11 +332,13 @@
- +
+ +
@@ -295,9 +389,11 @@
-
-
-
+
+
+
+
+
@@ -315,6 +411,14 @@
+
+
+ + + +
+
+
@@ -383,7 +487,7 @@ - + @@ -398,6 +502,7 @@ + diff --git a/options/donate_ltc.png b/options/donate_ltc.png new file mode 100644 index 0000000..5563402 Binary files /dev/null and b/options/donate_ltc.png differ diff --git a/options/options.css b/options/options.css index 4ac5c07..0b8bdf5 100644 --- a/options/options.css +++ b/options/options.css @@ -8,22 +8,37 @@ #donate { position:absolute; top:17px; - left:700px; + left:640px; width: 100px; height: 20px; background-image: url(../options/donate_title.svg); } +/* buttons are 35px apart */ #donate_paypal { position:absolute; top:14px; - left:790px; + left:755px; width: 32px; height: 32px; background-image: url(../options/donate_paypal.png); background-size: 30px 30px; } #donate_paypal:hover { + top: 13px; + left:754px; + background-size: 32px 32px; +} +#donate_litecoin { + position:absolute; + top:14px; + left:790px; + width: 32px; + height: 32px; + background-image: url(../options/donate_ltc.png); + background-size: 30px 30px; +} +#donate_litecoin:hover { top: 13px; left:789px; background-size: 32px 32px; @@ -98,4 +113,560 @@ ul:not(.menu) li { .label { padding-left: 6px; padding-right: 6px; -} \ No newline at end of file +} + + + + + + + + + + + + + + + + + + + + +/* THEME DEPARTMENT */ + + + +/* OPTIONS IMAGES */ +.font_color, +.font_weight_normal, +.font_weight_bold, +.font_style_normal, +.font_style_italic, +.color_toolbar_icon, +.color_bucket, +.color_brush, +.color_border, +.color_x, +.options_button_minus, +.options_button_plus { + z-index: 9000; + position: absolute; + display: float; + height: 20px; + width: 20px; + background-size: 20px 20px; +} + +.font_color { + background-image: url(../options/options_font_color.svg); +} +.font_color:hover { + background-image: url(../options/options_font_color_hover.svg); +} +.font_weight_normal { + background-image: url(../options/options_font_style_normal.svg); +} +.font_weight_normal:hover { + background-image: url(../options/options_font_style_normal_hover.svg); +} +.font_weight_bold { + background-image: url(../options/options_font_weight_bold.svg); +} +.font_weight_bold:hover { + background-image: url(../options/options_font_weight_bold_hover.svg); +} +.font_style_normal { + background-image: url(../options/options_font_style_normal.svg); +} +.font_style_normal:hover { + background-image: url(../options/options_font_style_normal_hover.svg); +} +.font_style_italic { + background-image: url(../options/options_font_style_italic.svg); +} +.font_style_italic:hover { + background-image: url(../options/options_font_style_italic_hover.svg); +} +.color_toolbar_icon { + background-image: url(../options/options_color_toolbar_icon.svg); +} +.color_toolbar_icon:hover { + background-image: url(../options/options_color_toolbar_icon_hover.svg); +} +.color_bucket { + background-image: url(../options/options_color_bucket.svg); +} +.color_bucket:hover { + background-image: url(../options/options_color_bucket_hover.svg); +} +.color_brush { + background-image: url(../options/options_color_brush.svg); +} +.color_brush:hover { + background-image: url(../options/options_color_brush_hover.svg); +} +.color_border { + background-image: url(../options/options_color_border.svg); +} +.color_border:hover { + background-image: url(../options/options_color_border_hover.svg); +} +.color_x { + background-image: url(../options/options_color_x.svg); +} +.color_x:hover { + background-image: url(../options/options_color_x_hover.svg); +} +.options_button_minus { + top: 5px; + left: 6px; + background-image: url(../options/options_scale_minus.svg); +} +.options_button_minus:hover { + background-image: url(../options/options_scale_minus_hover.svg); +} +.options_button_plus { + top: 5px; + left: 54px; + background-image: url(../options/options_scale_plus.svg); +} +.options_button_plus:hover { + background-image: url(../options/options_scale_plus_hover.svg); +} + +@keyframes hover_blinking { + 0% {background-color: transparent;} + 100% {background-color: blue;} +} +.hover_blinking { + animation: hover_blinking 1s infinite; +} + +@keyframes hover_border_blinking { + 0% {border: 1px solid transparent;} + 100% {border: 1px solid blue;} +} +.hover_border_blinking { + animation: hover_border_blinking 1s infinite; +} + +/* MAIN TOOLBAR */ +#toolbar_background { + top: 0px; + left: 307px; +} +#toolbar_border_bottom { + top: 0px; + left: 328px; +} + +#button_icons { + top: 0px; + left: 59px; +} +#button_icons_hover { + top: 0px; + left: 80px; +} + +#button_background { + top: 0px; + left: 4px; +} +#button_hover_background { + top: 0px; + left: 25px; +} + +#button_border { + top: 0px; + left: 115px; +} +#button_hover_border { + top: 0px; left: 136px; +} + +#filter_box_font { + top: 0px; + left: 175px; +} +#filter_clear_icon { + top: 0px; + left: 238px; +} +#filter_box_background { + top: 0px; + left: 196px; +} +#filter_box_border { + top: 0px; + left: 217px; +} + + +/* BIG OPTIONS BUTTONS */ +#options_tabs_margins_indicator { + z-index: 3000; + display: float; + position: absolute; + top: 25px; + left: 460px; + height: 30px; + width: 80px; + background-size: 80px 30px; + background-image: url(../options/options_tabs_margin_indicator.svg); +} +#options_tabs_indentation_indicator { + z-index: 3000; + display: float; + position: absolute; + top: 25px; + left: 550px; + height: 30px; + width: 80px; + background-size: 80px 30px; + background-image: url(../options/options_tabs_indentation_indicator.svg); +} +#options_tabs_roundness_indicator { + z-index: 3000; + display: float; + position: absolute; + top: 25px; + left: 640px; + height: 30px; + width: 80px; + background-size: 80px 30px; + background-image: url(../options/options_tabs_roundness_indicator.svg); +} +#options_tabs_size_indicator { + z-index: 3000; + display: float; + position: absolute; + top: 25px; left: 730px; + height: 30px; + width: 80px; + background-size: 80px 30px; + background-image: url(../options/options_tabs_size_indicator.svg); +} + +/* SCROLLBAR RESIZE */ +#scrollbar_size_indicator { + z-index: 3000; + display: float; + position: absolute; + top: 20px; + left: 335px; + height: 80px; + width: 80px; + background-size: 80px 80px; + background-image: url(../options/options_scrollbar_size_indicator.svg); +} +#options_tab_list_scrollbar_width_down { + left: 3px; + top: 30px; +} +#options_tab_list_scrollbar_width_up { + left: 57px; + top: 30px; +} +#options_tab_list_scrollbar_height_up { + left: 30px; + top: 3px; +} +#options_tab_list_scrollbar_height_down { + left: 30px; + top: 57px; +} + + +/* PIN LIST AND SCROLLBAR */ +#pin_list { + position: absolute; + height: calc(var(--scrollbar_height) + var(--pin_height) + 2px - var(--pin_list_padding_top) - var(--pin_list_padding_bottom)); + width: 788px; + top: 30px; + left: 20px; + padding: none; +} + +#pin_list_scrollbar { + position: absolute; + height: var(--scrollbar_height); + width: 790px; + top: calc(var(--pin_height) + 32px ); + left: 20px; z-index: 1000; + background-color: var(--scrollbar_track); +} +#pin_list_scrollbar_thumb { + position: relative; + height: 100%; + width: 100px; + top: 0px; + left: 0px; + z-index: 1200; + background-color: var(--scrollbar_thumb); +} +#pin_list_scrollbar_thumb:hover { + background-color: var(--scrollbar_thumb_hover); +} + + + +/* PINS */ +#pin_list_options_block { + z-index: 2000; + position:absolute; + width: 500px; + height: var(--pin_height); + top: 30px; + left: 20px; + margin: 0; + /* background:rgba(0,0,255,0.1); */ +} +#pin_list_background { + top: 1px; + left: 187px; +} +#pin_list_border_bottom { + top: 1px; + left: 164px; +} + + +/* ATTENTION PIN */ +#attention_background { + top: 1px; + left: 72px; +} +#attention_border { + top: 1px; + left: 93px; +} + + + +/* TAB LIST AND SCROLLBAR */ +#groups { + position: absolute; + height: 800px; + width: calc(771px - var(--scrollbar_width)); + top: calc(var(--scrollbar_height) + var(--pin_height) + 33px); + left: 40px; + z-index: 1000 +} + +#group_scrollbar { + position: absolute; + height: 800px; + width: var(--scrollbar_width); + top: calc(var(--scrollbar_height) + var(--pin_height) + 33px); + left: calc(810px - var(--scrollbar_width)); + z-index: 1000; + background-color: var(--scrollbar_track); +} +#group_scrollbar_thumb { + position: relative; + height: 200px; + width: 100%; + top: 140px; + left: 0px; + z-index: 1000; + background-color: var(--scrollbar_thumb); +} +#group_scrollbar_thumb:hover { + background-color: var(--scrollbar_thumb_hover); +} +#scrollbar_thumb { + position: absolute; + top: 370px; + left: 790px; +} +#scrollbar_thumb_hover { + position: absolute; + top: 390px; + left: 790px; +} +#scrollbar_track { + position: absolute; + top: 410px; + left: 790px; +} + +/* TABS */ +#tabs_options_block { + z-index: 2000; + position:absolute; + width: 740px; + height: auto; + top: calc(var(--scrollbar_height) + var(--pin_height) + 35px); + left: 50px; + margin: 0; + /* background:rgba(0,255,0,0.5); */ +} + +.tab_color_options_row { + z-index: 2000; + position:relative; + margin-top: var(--margin_top_tab); + width: 740px; + height: calc(var(--tab_height) + 2px); + /* background:rgba(255,0,0,0.1); */ +} +.tab_color_options_row .color_x, +.tab_color_options_row .color_border, +.tab_color_options_row .color_border, +.tab_color_options_row .color_bucket, +.tab_color_options_row .font_color, +.tab_color_options_row .font_weight_normal, +.tab_color_options_row .font_weight_bold, +.tab_color_options_row .font_style_normal, +.tab_color_options_row .font_style_italic { + top: 0px; + height: var(--tab_height); + width: var(--tab_height); + background-size: var(--tab_height) var(--tab_height); +} + +.tab_color_options_row>.color_border { + left: 659px; +} +.tab_color_options_row>.color_bucket { + left: 680px; +} +.tab_color_options_row>.font_color { + left: 509px; +} +.tab_color_options_row>.font_weight_normal { + left: 538px; +} +.tab_color_options_row>.font_weight_bold { + left: 559px; +} +.tab_color_options_row>.font_style_normal { + left: 588px; +} +.tab_color_options_row>.font_style_italic { + left: 609px; +} + + +/* DRAG AND DROP INDICATOR */ +#dd19 { + display: inline-block; + border-bottom: 2px solid var(--drag_indicator); +} +#drag_indicator { + top: calc(var(--tab_height) / 2); + left: 350px; +} + + +/* CLOSE TAB BUTTON OPTIONS */ +#close_x { + top: 0px; + left: calc(753px - var(--scrollbar_width)); +} +#close_hover_x { + top: calc(-1* var(--tab_height)); + left: calc(753px - var(--scrollbar_width)); +} +#close_hover_border { + top: 0px; + left: calc(753px - var(--scrollbar_width)); +} +#close_hover_background { + top: var(--tab_height); + left: calc(753px - var(--scrollbar_width)); +} + + +/* CLOSE TAB BUTTON OPTIONS */ +#expand_hover_background { + top: 0px; + left: calc(var(--children_padding_left) - 18px); +} +#expand_closed_background { + top: 0px; + left: calc(var(--children_padding_left) - 18px); +} +#expand_open_background { + top: 0px; left: -12px; +} + + +#tab_list_background { + top: 835px; + left: 50px; +} + + + +#toolbar_groups_block { + position: absolute; + left: 20px; + top: calc(var(--scrollbar_height) + var(--pin_height) + 33px); + width: 19px; + height: 800px; + background-color: var(--group_list_background); + border-right: 1px solid var(--group_list_borders); + overflow: visible; +} +#_gtetab_list { + width: 200px; + height: 20px; +} +#_gtetab_list2 { + width: 200px; + height: 20px; +} +#_tab_list2:hover { + background-color: var(--group_list_button_hover_background); +} + +#group_list_background { + top: 835px; + left: 20px; +} +#group_list_borders { + top: 631px; + left: 20px; +} +#group_list_default_font_color { + top: 652px; + left: 20px; +} +#group_list_button_hover_background { + top: 610px; + left: 20px; +} + + +/* MENU */ +#tabs_menu_border { + top: 59px; + left: 80px; +} +#tabs_menu_background { + top: 59px; + left: 102px; +} +#tabs_menu_font { + top: 36px; + left: 102px; +} +#tabs_menu_hover_border { + top: 14px; + left: 80px; +} +#tabs_menu_hover_background { + top: 14px; + left: 102px; +} +#tabs_menu_separator { + top: 36px; + left: 80px; +} + + diff --git a/options/options.js b/options/options.js index 854135d..d2267bc 100644 --- a/options/options.js +++ b/options/options.js @@ -10,6 +10,9 @@ var SelectedTheme = Object.assign({}, DefaultTheme); var dragged_button; active_group = "tab_list"; +// options for all drop down menus +let DropDownList = ["dbclick_folder", "midclick_folder", "midclick_tab", "dbclick_group", "midclick_group", "dbclick_tab", "append_child_tab", "append_child_tab_after_limit", "append_orphan_tab", "after_closing_active_tab"]; + document.addEventListener("DOMContentLoaded", function() { document.title = "Tree Tabs"; chrome.runtime.sendMessage({command: "get_preferences"}, function(response) { @@ -27,9 +30,8 @@ document.addEventListener("DOMContentLoaded", function() { GetOptions(); RefreshFields(); SetEvents(); - SetToolbarShelfToggle("click"); - AppendGroupToList("tab_list", caption_ungrouped_group, ""); - AppendGroupToList("tab_list2", caption_noname_group, ""); + AppendGroupToList("tab_list", caption_ungrouped_group, "", false); + AppendGroupToList("tab_list2", caption_noname_group, "", false); AppendSampleTabs(); }); }); @@ -38,567 +40,626 @@ document.addEventListener("DOMContentLoaded", function() { // document events function GetOptions() { // get language labels - $(".label").each(function() { - $(this).text(chrome.i18n.getMessage(this.id)); - }); - // get language for color pick labels - $(".cpl").each(function() { - $(this).text(chrome.i18n.getMessage(this.id)); - }); + document.querySelectorAll(".label, .set_button, .bg_opt_drop_down_menu").forEach(function(s){ + s.textContent = chrome.i18n.getMessage(s.id); + }); + // get language for menu labels - $(".menu_item").each(function() { - $(this).text(chrome.i18n.getMessage("options_example_menu_item")); - }); + document.querySelectorAll(".menu_item").forEach(function(s){ + s.textContent = chrome.i18n.getMessage("options_example_menu_item"); + }); // get checkboxes from saved states - $(".opt_checkbox").each(function() { - $(this)[0].checked = opt[this.id]; - }); - $(".set_button").each(function() { - $(this)[0].textContent = chrome.i18n.getMessage(this.id); - }); - - // get language dropdown menus - $(".bg_opt_drop_down_menu").each(function() { - $(this)[0].textContent = chrome.i18n.getMessage(this.id); - }); - - // get language for color pick labels - $("#close_x, #close_hover_x").each(function() { - $(this).attr("title", chrome.i18n.getMessage(this.id)); - }); - $(".color_border").each(function() { - $(this).attr("title", chrome.i18n.getMessage("options_color_pick_border")); - }); - $(".color_bucket").each(function() { - $(this).attr("title", chrome.i18n.getMessage("options_color_pick_background")); - }); - $(".pick_col_hover").each(function() { - $(this).attr("title", chrome.i18n.getMessage("options_color_pick_hover")); - }); - $(".font_color").each(function() { - $(this).attr("title", chrome.i18n.getMessage("options_color_pick_font")); - }); - - $(".options_button_minus, .options_button_plus").each(function() { - $(this).attr("title", chrome.i18n.getMessage(this.id)); - }); - $("#filter_clear_icon").each(function() { - $(this).attr("title", chrome.i18n.getMessage("options_color_pick_filter_clear_icon")); - }); - - // get options for append child tab - for (var i = 0; i < $("#append_child_tab")[0].options.length; i++) { - if ($("#append_child_tab")[0].options[i].value === opt.append_child_tab) { - $("#append_child_tab")[0].selectedIndex = i; - break; + document.querySelectorAll(".opt_checkbox").forEach(function(s){ + s.checked = opt[s.id]; + if (s.checked) { + if (s.id == "never_show_close") { + document.getElementById("always_show_close").disabled = true; + } + } else { + if (s.id == "promote_children") { + document.getElementById("promote_children_in_first_child").disabled = true; + } } - } + }); + + // get language labels + document.querySelectorAll(".pick_col, #close_x, #close_hover_x, .options_button_minus, .options_button_plus, .tabs_margin_spacing").forEach(function(s){ + s.title = chrome.i18n.getMessage(s.id); + }); + - // get options for append child tab after limit - for (var i = 0; i < $("#append_child_tab_after_limit")[0].options.length; i++) { - if ($("#append_child_tab_after_limit")[0].options[i].value === opt.append_child_tab_after_limit) { - $("#append_child_tab_after_limit")[0].selectedIndex = i; - break; - } - } - - // get options for append orphan tab - for (var i = 0; i < $("#append_orphan_tab")[0].options.length; i++) { - if ($("#append_orphan_tab")[0].options[i].value === opt.append_orphan_tab) { - $("#append_orphan_tab")[0].selectedIndex = i; - break; - } - } - - // get options for action after closing active tab - for (var i = 0; i < $("#after_closing_active_tab")[0].options.length; i++) { - if ($("#after_closing_active_tab")[0].options[i].value === opt.after_closing_active_tab) { - $("#after_closing_active_tab")[0].selectedIndex = i; - break; + + + + // get options for all drop down menus (loop through all drop down items that are in DropDownList array) + for (let i = 0; i < DropDownList.length; i++) { + let DropDownOption = document.getElementById(DropDownList[i]); + for (let j = 0; j < DropDownOption.options.length; j++) { + if (DropDownOption.options[j].value == opt[DropDownList[i]]) { + DropDownOption.selectedIndex = j; + break; + } } } // get options for tabs tree depth option - $("#max_tree_depth")[0].value = opt.max_tree_depth; + document.getElementById("max_tree_depth").value = opt.max_tree_depth; + // append themes to dropdown menu + let ThemeList = document.getElementById("theme_list"); for (var i = 0; i < themes.length; i++) { - var t_list = document.getElementById("theme_list"); - var theme_name = document.createElement("option"); - theme_name.value = themes[i]; - theme_name.text = themes[i]; - t_list.add(theme_name); + let theme_name = document.createElement("option"); + theme_name.value = themes[i]; + theme_name.text = themes[i]; + ThemeList.add(theme_name); } - // select current theme in dropdown list - for (var i = 0; i < $("#theme_list")[0].options.length; i++) { - if ($("#theme_list")[0].options[i].value == current_theme) { - $("#theme_list")[0].selectedIndex = i; + for (var i = 0; i < ThemeList.options.length; i++) { + if (ThemeList.options[i].value == current_theme) { + ThemeList.selectedIndex = i; break; } } } -function RemoveRedPreview() { +function RemovePreview() { if (document.styleSheets[document.styleSheets.length-1].cssRules.length) { document.styleSheets[document.styleSheets.length-1].deleteRule(document.styleSheets[document.styleSheets.length-1].cssRules.length-1); } + document.querySelectorAll(".hover_blinking").forEach(function(s){s.classList.remove("hover_blinking");}); + document.querySelectorAll(".hover_border_blinking").forEach(function(s){s.classList.remove("hover_border_blinking");}); } // document events function SetEvents() { -// --------------------------------DONATIONS------------------------------------------------------------------------------ +// --------------------------------DONATIONS----------------------------------------------------------------------------- - // Donate - $(document).on("click", "#options_share_theme_link", function(event) { - chrome.tabs.create({url: "https://drive.google.com/drive/folders/0B3jXQpRtOfvSelFrTEVHZEx3Nms?usp=sharing"}); - }); - - $(document).on("click", "#donate_paypal", function(event) { + document.getElementById("donate_paypal").onclick = function(event) {if (event.which == 1) { chrome.tabs.create({url: "https://www.paypal.me/KarolJagiello/1"}); - }); - - $(document).on("click", "#donate_bitcoin", function(event) { + }} + document.getElementById("donate_litecoin").onclick = function(event) {if (event.which == 1) { + copyStringToClipboard("LdQ1ZH1CgSneBbmmVBFrg5BFDFHZMa6h76"); + alert(chrome.i18n.getMessage("options_copied_wallet_address")); + }} + document.getElementById("donate_bitcoin").onclick = function(event) {if (event.which == 1) { copyStringToClipboard("19Z8w1RJEcBQpKSdiWa3UTBuKRJUkr96nJ"); alert(chrome.i18n.getMessage("options_copied_wallet_address")); - }); - - $(document).on("click", "#donate_ethereum", function(event) { + }} + document.getElementById("donate_ethereum").onclick = function(event) {if (event.which == 1) { copyStringToClipboard("0x70B05eAD03bF08220d5aF4E1E868C351bfe145D6"); alert(chrome.i18n.getMessage("options_copied_wallet_address")); - }); - + }} // --------------------------------COPY VIVALDI LINK---------------------------------------------------------------------- - $(document).on("click", "#copy_vivaldi_url_for_web_panel", function(event) { - copyStringToClipboard(chrome.runtime.getURL("sidebar.html")); - alert(chrome.i18n.getMessage("options_vivaldi_copied_url")); - }); + document.getElementById("copy_vivaldi_url_for_web_panel").onclick = function(event) {if (event.which == 1) { + copyStringToClipboard(chrome.runtime.getURL("sidebar.html")); + alert(chrome.i18n.getMessage("options_vivaldi_copied_url")); + }} -// --------------------------------ADD RED PREVIEW------------------------------------------------------------------------ - - $(document).on("mouseenter", ".pick_col, #filter_box_font", function(event) { +// --------------------------------ADD RED AND BLUE PREVIEWS--------------------------------------------------------------- + // document.body.onmousedown = function(event) { + // if (event.which == 1 && (event.target.id || event.target.classList)) { + // console.log(event.target); + // } + // } + document.querySelectorAll(".pick_col, #filter_box_font").forEach(function(s){s.onmouseenter = function(event) { document.styleSheets[document.styleSheets.length-1].insertRule("body { --"+this.id+": red; }", document.styleSheets[document.styleSheets.length-1].cssRules.length); - }); - $(document).on("mouseenter", ".font_weight_normal", function(event) { + }}); + document.querySelectorAll(".font_weight_normal").forEach(function(s){s.onmouseenter = function(event) { document.styleSheets[document.styleSheets.length-1].insertRule("body { --"+this.id+": normal; }", document.styleSheets[document.styleSheets.length-1].cssRules.length); - }); - $(document).on("mouseenter", ".font_weight_bold", function(event) { + }}); + document.querySelectorAll(".font_weight_bold").forEach(function(s){s.onmouseenter = function(event) { document.styleSheets[document.styleSheets.length-1].insertRule("body { --"+this.id+": bold; }", document.styleSheets[document.styleSheets.length-1].cssRules.length); - }); - - $(document).on("mouseenter", ".font_style_normal", function(event) { + }}); + document.querySelectorAll(".font_style_normal").forEach(function(s){s.onmouseenter = function(event) { document.styleSheets[document.styleSheets.length-1].insertRule("body { --"+this.id+": normal; }", document.styleSheets[document.styleSheets.length-1].cssRules.length); - }); - $(document).on("mouseenter", ".font_style_italic", function(event) { + }}); + document.querySelectorAll(".font_style_italic").forEach(function(s){s.onmouseenter = function(event) { document.styleSheets[document.styleSheets.length-1].insertRule("body { --"+this.id+": italic; }", document.styleSheets[document.styleSheets.length-1].cssRules.length); - }); + }}); + document.querySelectorAll(".pick_col, .font_weight_normal, .font_weight_bold, .font_style_normal, .font_style_italic, #filter_box_font").forEach(function(s){s.onmouseleave = function(event) { + RemovePreview(); + }}); - $(document).on("mouseleave", ".pick_col, .font_weight_normal, .font_weight_bold, .font_style_normal, .font_style_italic, #filter_box_font", function(event) { - RemoveRedPreview(); - }); - - $(document).on("mouseenter", "#scrollbar_thumb_hover", function(event) { - $("#group_scrollbar_thumb, #pin_list_scrollbar_thumb").addClass("hover_blinking"); - }); - - $(document).on("mouseleave", "#scrollbar_thumb_hover", function(event) { - $("#group_scrollbar_thumb, #pin_list_scrollbar_thumb").removeClass("hover_blinking"); - }); - - $(document).on("mouseenter", "#group_list_button_hover_background", function(event) { - $("#_tab_list2").addClass("hover_blinking"); - }); - - $(document).on("mouseleave", "#group_list_button_hover_background", function(event) { - $("#_tab_list2").removeClass("hover_blinking"); - }); - - $(document).on("mouseenter", "#button_hover_background", function(event) { - $(".button").addClass("hover_blinking"); - }); - $(document).on("mouseleave", "#button_hover_background", function(event) { - $(".button").removeClass("hover_blinking"); - }); - - $(document).on("mouseenter", "#button_icons_hover", function(event) { - $(".button_img").addClass("hover_blinking"); - }); - $(document).on("mouseleave", "#button_icons_hover", function(event) { - $(".button_img").removeClass("hover_blinking"); - }); - - $(document).on("mouseenter", "#button_hover_border", function(event) { - $(".button").addClass("hover_border_blinking"); - }); - $(document).on("mouseleave", "#button_hover_border", function(event) { - $(".button").removeClass("hover_border_blinking"); - }); - - - - // filter_box_font - $(document).on("mouseenter", "#options_tab_list_scrollbar_width_up, #options_tab_list_scrollbar_width_down", function(event) { - $("#group_scrollbar, #group_scrollbar_thumb").css({ "background-color": "red" }); - }); - $(document).on("mouseleave", "#options_tab_list_scrollbar_width_up, #options_tab_list_scrollbar_width_down", function(event) { - $("#group_scrollbar, #group_scrollbar_thumb").css({ "background-color": "" }); - }); + document.getElementById("group_list_default_font_color").onmouseenter = function(event) { + document.getElementById("_gtetab_list").style.color = "red"; + document.getElementById("_gtetab_list2").style.color = "red"; + + } + document.getElementById("group_list_default_font_color").onmouseleave = function(event) { + document.getElementById("_gtetab_list").style.color = ""; + document.getElementById("_gtetab_list2").style.color = ""; + } + - $(document).on("mouseenter", "#options_tab_list_scrollbar_height_up, #options_tab_list_scrollbar_height_down", function(event) { - $("#pin_list_scrollbar, #pin_list_scrollbar_thumb").css({ "background-color": "red" }); - }); - $(document).on("mouseleave", "#options_tab_list_scrollbar_height_up, #options_tab_list_scrollbar_height_down", function(event) { - $("#pin_list_scrollbar, #pin_list_scrollbar_thumb").css({ "background-color": "" }); - }); + document.getElementById("scrollbar_thumb_hover").onmouseenter = function(event) { + RemovePreview(); + document.getElementById("group_scrollbar_thumb").classList.add("hover_blinking"); + document.getElementById("pin_list_scrollbar_thumb").classList.add("hover_blinking"); + } + document.getElementById("scrollbar_thumb_hover").onmouseleave = function(event) { + RemovePreview(); + } + document.getElementById("group_list_button_hover_background").onmouseenter = function(event) { + RemovePreview(); + document.getElementById("_tab_list2").classList.add("hover_blinking"); + } + document.getElementById("group_list_button_hover_background").onmouseleave = function(event) { + RemovePreview(); + } + + document.getElementById("button_hover_background").onmouseenter = function(event) { + RemovePreview(); + document.querySelectorAll(".button").forEach(function(s){s.classList.add("hover_blinking");}); + } + document.getElementById("button_hover_background").onmouseleave = function(event) { + RemovePreview(); + } + + + + document.getElementById("button_icons_hover").onmouseenter = function(event) { + RemovePreview(); + document.querySelectorAll(".button_img").forEach(function(s){s.classList.remove("hover_blinking");}); + } + document.getElementById("button_icons_hover").onmouseleave = function(event) { + RemovePreview(); + } + + document.getElementById("button_hover_border").onmouseenter = function(event) { + RemovePreview(); + document.querySelectorAll(".button").forEach(function(s){s.classList.add("hover_border_blinking");}); + } + document.getElementById("button_hover_border").onmouseleave = function(event) { + RemovePreview(); + } + + document.getElementById("options_tab_list_scrollbar_width_up").onmouseenter = function(event) { + document.getElementById("group_scrollbar").style.backgroundColor = "red"; + document.getElementById("group_scrollbar_thumb").style.backgroundColor = "red"; + } + document.getElementById("options_tab_list_scrollbar_width_down").onmouseenter = function(event) { + document.getElementById("group_scrollbar").style.backgroundColor = "red"; + document.getElementById("group_scrollbar_thumb").style.backgroundColor = "red"; + } + + document.getElementById("options_tab_list_scrollbar_width_up").onmouseleave = function(event) { + document.getElementById("group_scrollbar").style.backgroundColor = ""; + document.getElementById("group_scrollbar_thumb").style.backgroundColor = ""; + } + document.getElementById("options_tab_list_scrollbar_width_down").onmouseleave = function(event) { + document.getElementById("group_scrollbar").style.backgroundColor = ""; + document.getElementById("group_scrollbar_thumb").style.backgroundColor = ""; + } + + + + document.getElementById("options_tab_list_scrollbar_height_up").onmouseenter = function(event) { + document.getElementById("pin_list_scrollbar").style.backgroundColor = "red"; + document.getElementById("pin_list_scrollbar_thumb").style.backgroundColor = "red"; + } + document.getElementById("options_tab_list_scrollbar_height_down").onmouseenter = function(event) { + document.getElementById("pin_list_scrollbar").style.backgroundColor = "red"; + document.getElementById("pin_list_scrollbar_thumb").style.backgroundColor = "red"; + } + + document.getElementById("options_tab_list_scrollbar_height_up").onmouseleave = function(event) { + document.getElementById("pin_list_scrollbar").style.backgroundColor = ""; + document.getElementById("pin_list_scrollbar_thumb").style.backgroundColor = ""; + } + document.getElementById("options_tab_list_scrollbar_height_down").onmouseleave = function(event) { + document.getElementById("pin_list_scrollbar").style.backgroundColor = ""; + document.getElementById("pin_list_scrollbar_thumb").style.backgroundColor = ""; + } + // --------------------------------------COLOR PICKER--------------------------------------------------------------------- - // change fonts weight - $(document).on("mousedown", ".font_weight_normal, .font_weight_bold", function(event) { + // change fonts weight && style + document.querySelectorAll(".font_weight_normal, .font_weight_bold, .font_style_normal, .font_style_italic").forEach(function(s){s.onmousedown = function(event) { event.stopPropagation(); - SelectedTheme["ColorsSet"][this.id] = $(this).is(".font_weight_normal") ? "normal" : "bold"; + // if this.classList.contains("font_weight_normal") || this.classList.contains("font_style_normal") + let FontStyle = "normal"; + if (this.classList.contains("font_weight_bold")) { + FontStyle = "bold"; + } + if (this.classList.contains("font_style_italic")) { + FontStyle = "italic"; + } + SelectedTheme["ColorsSet"][this.id] = FontStyle; ApplyColorsSet(SelectedTheme["ColorsSet"]); - SaveTheme($("#theme_list").val()); - }); - - // change fonts style - $(document).on("mousedown", ".font_style_normal, .font_style_italic", function(event) { - event.stopPropagation(); - SelectedTheme["ColorsSet"][this.id] = $(this).is(".font_style_normal") ? "normal" : "italic"; - ApplyColorsSet(SelectedTheme["ColorsSet"]); - SaveTheme($("#theme_list").val()); - }); - - + SaveTheme(document.getElementById("theme_list").value); + }}); + // show color picker - $(document).on("click", ".pick_col", function(event) { - RemoveRedPreview(); + document.querySelectorAll(".pick_col").forEach(function(s){s.onclick = function(event) {if (event.which == 1) { + RemovePreview(); event.stopPropagation(); - PickColor = this.id; let bod = document.getElementById("body"); let color = window.getComputedStyle(bod, null).getPropertyValue("--"+this.id); - $("#color_picker")[0].value = color.replace(" ", ""); - $("#color_picker").click(); - }); - $(document).on("input", "#color_picker", function(event) { - event.stopPropagation(); - SelectedTheme["ColorsSet"][PickColor] = $("#color_picker")[0].value; + let ColorPicker = document.getElementById("color_picker"); + ColorPicker.setAttribute("PickColor", this.id); + ColorPicker.value = color.replace(" ", ""); + ColorPicker.click(); + }}}); + + document.getElementById("color_picker").oninput = function(event) { + let ColorPicker = document.getElementById("color_picker"); + SelectedTheme["ColorsSet"][this.getAttribute("PickColor")] = ColorPicker.value; ApplyColorsSet(SelectedTheme["ColorsSet"]); - SaveTheme($("#theme_list").val()); - }); - - + // SaveTheme(document.getElementById("theme_list").value); + } + document.getElementById("color_picker").onchange = function(event) { + SaveTheme(document.getElementById("theme_list").value); + } + + // ----------------------------------EVENTS FOR CHECKBOXES AND DROPDOWN MENUS--------------------------------------------- + // set checkbox options on/off and save - $(document).on("click", ".bg_opt", function(event) { - opt[this.id] = $(this)[0].checked ? true : false; + document.querySelectorAll(".bg_opt").forEach(function(s){s.onclick = function(event) {if (event.which == 1) { + opt[this.id] = this.checked ? true : false; + if (this.checked) { + if (this.id == "never_show_close") { + document.getElementById("always_show_close").disabled = true; + } + if (this.id == "promote_children") { + document.getElementById("promote_children_in_first_child").disabled = false; + } + } else { + if (this.id == "never_show_close") { + document.getElementById("always_show_close").disabled = false; + } + if (this.id == "promote_children") { + document.getElementById("promote_children_in_first_child").disabled = true; + } + } SavePreferences(); - }); + }}}); + // options that need reload - $(document).on("click", "#syncro_tabbar_tabs_order, #allow_pin_close, #switch_with_scroll, #always_show_close, #never_show_close, #close_other_trees, #show_counter_tabs, #show_counter_tabs_hints, #syncro_tabbar_tabs_order, #syncro_tabbar_groups_tabs_order", function(event) { - chrome.runtime.sendMessage({command: "reload_sidebar"}); - }); - - // options that need a total reload - $(document).on("click", "#groups_toolbar_default", function(event) { - chrome.runtime.sendMessage({command: "reload"}); - chrome.runtime.sendMessage({command: "reload_sidebar"}); - location.reload(); - }); + document.onclick = function(event) {if (event.which == 1) { + if (event.target.id == "show_toolbar" || event.target.id == "syncro_tabbar_tabs_order" || event.target.id == "allow_pin_close" || event.target.id == "switch_with_scroll" || event.target.id == "always_show_close" || event.target.id == "never_show_close" || + event.target.id == "collapse_other_trees" || event.target.id == "show_counter_tabs" || event.target.id == "show_counter_tabs_hints" || event.target.id == "syncro_tabbar_tabs_order" || event.target.id == "syncro_tabbar_groups_tabs_order" || event.target.id == "groups_toolbar_default") { + chrome.runtime.sendMessage({command: "reload_sidebar"}); + } + if (event.target.id == "groups_toolbar_default") { + chrome.runtime.sendMessage({command: "reload"}); + setTimeout(function() { + location.reload(); + }, 300); + } + }} // set dropdown menu options - $("#append_child_tab, #append_child_tab_after_limit, #after_closing_active_tab, #append_orphan_tab").change(function() { - opt[this.id] = $(this).val(); - SavePreferences(); - }); + for (let i = 0; i < DropDownList.length; i++) { + document.getElementById(DropDownList[i]).onchange = function(event) { +console.log(opt[this.id]); +console.log(this.value); + opt[this.id] = this.value; + SavePreferences(); + chrome.runtime.sendMessage({command: "reload_sidebar"}); + } + } - // set tabs tree depth option - $(document).on("input", "#max_tree_depth", function(event) { - opt.max_tree_depth = $(this)[0].value; + document.getElementById("max_tree_depth").oninput = function(event) { + opt.max_tree_depth = parseInt(this.value); SavePreferences(); - }); - + chrome.runtime.sendMessage({command: "reload_sidebar"}); + } // set toolbar on/off and show/hide all toolbar options - $(document).on("click", "#show_toolbar", function(event) { - SelectedTheme.ToolbarShow = $("#show_toolbar")[0].checked ? true : false; - SaveTheme($("#theme_list").val()); - LoadTheme($("#theme_list").val()); - }); + document.getElementById("show_toolbar").onclick = function(event) {if (event.which == 1) { + SelectedTheme.ToolbarShow = this.checked ? true : false; + RefreshFields(); + SaveTheme(document.getElementById("theme_list").value); + }} // ------------------------------OTHER------------------------------------------------------------------------------------ // block system dragging - $(document).bind("drop dragover", function(event) { + document.ondrop = function(event) { event.preventDefault(); - }); + } + document.ondragover = function(event) { + event.preventDefault(); + } -// ----------------------------TOOLBAR CUSTOMIZATION---------------------------------------------------------------------- - - - $(document).on("mousedown", ".button", function(event) { - $("#button_filter_clear").css({"opacity": "1", "position": "absolute"}); - if ($(this).is("#button_filter_type, #filter_search_go_prev, #filter_search_go_next")) { - return; - } - $(this).attr("draggable", "true"); - dragged_button = this; - }); +// ----------------------------RESET TOOLBAR BUTTON----------------------------------------------------------------------- - // set dragged button node - $(document).on("dragstart", ".button", function(event) { - event.originalEvent.dataTransfer.setData(" "," "); - event.originalEvent.dataTransfer.setDragImage(document.getElementById("DragImage"), 0, 0); - }); - - // remove draggable attribute to clean html which will be saved in the toolbar - $(document).on("mouseleave", ".button", function(event) { - $(".button").removeAttr("draggable"); - }); - - - - // drag&drop buttons to lists - $(document).on("dragenter", "#toolbar_main, .toolbar_shelf, #toolbar_unused_buttons", function(event) { - if ($(dragged_button).is("#button_tools, #button_search, #button_groups, #button_backup, #button_folders") && $(this).is(".toolbar_shelf")) { - return; - } - if (dragged_button.parentNode.id != this.id) { - // if ($(dragged_button).is("#button_tools, #button_search, #button_groups, #button_backup, #button_folders") && $(this).is("#toolbar_unused_buttons")) { - // $(".on").removeClass("on"); - // } - $("#"+dragged_button.id).appendTo($(this)); - } - }); - - // move (flip) buttons - $(document).on("dragenter", ".button", function(event) { - if ($(dragged_button).is("#button_tools, #button_search, #button_groups, #button_backup, #button_folders") && $(this).parent().is(".toolbar_shelf")) { - return; - } - if ($(this).parent().is("#toolbar_search, #toolbar_search_buttons")) { - return; - } - if ( $(this).index() <= $("#"+dragged_button.id).index()) { - $("#"+dragged_button.id).insertBefore($(this)); - } else { - $("#"+dragged_button.id).insertAfter($(this)); - } - }); - - // save toolbar - $(document).on("dragend", ".button", function(event) { - $("#button_filter_clear").css({"opacity": "0"}); - - SelectedTheme.toolbar = $("#toolbar").html(); - SelectedTheme.unused_buttons = $("#toolbar_unused_buttons").html(); - SaveTheme($("#theme_list").val()); - $("#button_filter_clear").css({"opacity": "1"}); - }); - - // reset toolbar - $(document).on("click", "#options_reset_toolbar_button", function(event) { + document.getElementById("options_reset_toolbar_button").onclick = function(event) {if (event.which == 1) { + SetToolbarEvents(true, false, false, ""); + RemoveToolbarEditEvents(); SelectedTheme["toolbar"] = DefaultToolbar; SelectedTheme["unused_buttons"] = ""; - $("#toolbar").html(DefaultToolbar); - $("#toolbar_unused_buttons").html(""); - SaveTheme($("#theme_list").val()); - $(".on").removeClass("on"); + document.getElementById("toolbar").innerHTML = DefaultToolbar; + document.getElementById("toolbar_unused_buttons").innerHTML = ""; + SaveTheme(document.getElementById("theme_list").value); + document.querySelectorAll(".on").forEach(function(s){s.classList.remove("on");}); RefreshGUI(); - }); + SetToolbarEvents(false, false, true, "click"); + AddEditToolbarEditEvents(); + }} // --------------------------------------THEME BUTTONS-------------------------------------------------------------------- // add new theme preset button - $(document).on("click", "#options_add_theme_button", function(event) { + document.getElementById("options_add_theme_button").onclick = function(event) {if (event.which == 1) { AddNewTheme(); - }); + }} // remove theme preset button - $(document).on("click", "#options_remove_theme_button", function(event) { + document.getElementById("options_remove_theme_button").onclick = function(event) {if (event.which == 1) { DeleteSelectedTheme(); - }); + }} // select theme from list - $("#theme_list").change(function() { - LoadTheme($(this).val()); - chrome.storage.local.set({current_theme: $(this).val()}); - }); + document.getElementById("theme_list").onchange = function(event) { + LoadTheme(this.value, true); + chrome.storage.local.set({current_theme: this.value}); + } // import theme preset button - $(document).on("click", "#options_import_theme_button", function(event) { - ShowOpenFileDialog("import_theme", ".tt_theme"); - }); - $(document).on("change", "#import_theme", function(event) { - ImportTheme(); - }); - + document.getElementById("options_import_theme_button").onclick = function(event) {if (event.which == 1) { + let inputFile = ShowOpenFileDialog("import_theme", ".tt_theme"); + inputFile.onchange = function(event) { + ImportTheme(); + } + }} + // export theme preset button - $(document).on("click", "#options_export_theme_button", function(event) { - if ($("#theme_list")[0].options.length == 0) { + document.getElementById("options_export_theme_button").onclick = function(event) {if (event.which == 1) { + if (document.getElementById("theme_list").options.length == 0) { alert(chrome.i18n.getMessage("options_no_theme_to_export")); } else { - SaveFile($("#theme_list").val() + ".tt_theme", SelectedTheme); + SaveFile(document.getElementById("theme_list").value + ".tt_theme", SelectedTheme); } - }); + }} // rename theme preset button - $(document).on("click", "#options_rename_theme_button", function(event) { + document.getElementById("options_rename_theme_button").onclick = function(event) {if (event.which == 1) { RenameSelectedTheme(); - }); + }} + // get themes + document.getElementById("options_share_theme_link").onclick = function(event) {if (event.which == 1) { + chrome.tabs.create({url: "https://drive.google.com/drive/folders/0B3jXQpRtOfvSelFrTEVHZEx3Nms?usp=sharing"}); + }} // -------------------------------INDENTATION ADJUSTMENT------------------------------------------------------------------ // change tabs size preset(down) - $(document).on("click", "#options_tabs_indentation_down", function(event) { + document.getElementById("options_tabs_indentation_down").onmousedown = function(event) { let bod = document.getElementById("body"); var indentation = parseInt((window.getComputedStyle(bod, null).getPropertyValue("--children_padding_left")).replace("p","").replace("x","")); if (indentation > 0) { indentation--; SelectedTheme["ColorsSet"]["children_padding_left"] = indentation+"px"; ApplyColorsSet(SelectedTheme["ColorsSet"]); - SaveTheme($("#theme_list").val()); + SaveTheme(document.getElementById("theme_list").value); } - }); + } // change tabs size preset(up) - $(document).on("click", "#options_tabs_indentation_up", function(event) { + document.getElementById("options_tabs_indentation_up").onmousedown = function(event) { let bod = document.getElementById("body"); var indentation = parseInt((window.getComputedStyle(bod, null).getPropertyValue("--children_padding_left")).replace("p","").replace("x","")); if (indentation < 50) { indentation++; SelectedTheme["ColorsSet"]["children_padding_left"] = indentation+"px"; ApplyColorsSet(SelectedTheme["ColorsSet"]); - SaveTheme($("#theme_list").val()); + SaveTheme(document.getElementById("theme_list").value); } - }); + } // --------------------------TABS ROUNDNESS ADJUSTMENT-------------------------------------------------------------------- // change tabs roundness preset(down) - $(document).on("click", "#options_tabs_roundness_down", function(event) { + document.getElementById("options_tabs_roundness_down").onmousedown = function(event) { let bod = document.getElementById("body"); var border_radius = parseInt((window.getComputedStyle(bod, null).getPropertyValue("--tab_header_border_radius").replace("p","").replace("x",""))); if (border_radius > 0) { border_radius--; SelectedTheme["ColorsSet"]["tab_header_border_radius"] = border_radius+"px"; ApplyColorsSet(SelectedTheme["ColorsSet"]); - SaveTheme($("#theme_list").val()); + SaveTheme(document.getElementById("theme_list").value); } - }); + } // change tabs roundness preset(up) - $(document).on("click", "#options_tabs_roundness_up", function(event) { + document.getElementById("options_tabs_roundness_up").onmousedown = function(event) { let bod = document.getElementById("body"); var border_radius = parseInt((window.getComputedStyle(bod, null).getPropertyValue("--tab_header_border_radius")).replace("p","").replace("x","")); if (border_radius < 25) { border_radius++; SelectedTheme["ColorsSet"]["tab_header_border_radius"] = border_radius+"px"; ApplyColorsSet(SelectedTheme["ColorsSet"]); - SaveTheme($("#theme_list").val()); + SaveTheme(document.getElementById("theme_list").value); } - }); + } // -------------------------------SIZE ADJUSTMENT------------------------------------------------------------------------- + // set tabs margins + document.getElementById("tabs_margin_spacing").onchange = function(event) { + let size = "0"; + if (this[1].checked) { + size = "1"; + } else { + if (this[2].checked) { + size = "2"; + } + } + SelectedTheme["TabsMargins"] = size; + ApplyTabsMargins(size); + SaveTheme(document.getElementById("theme_list").value); + } + + // change tabs size preset(down) - $(document).on("click", "#options_tabs_size_down", function(event) { + document.getElementById("options_tabs_size_down").onmousedown = function(event) { if (SelectedTheme["TabsSizeSetNumber"] > 0) { SelectedTheme["TabsSizeSetNumber"]--; ApplySizeSet(SelectedTheme["TabsSizeSetNumber"]); - ApplySizeOptionsSet(SelectedTheme["TabsSizeSetNumber"]); - SaveTheme($("#theme_list").val()); + SaveTheme(document.getElementById("theme_list").value); } - }); + } // change tabs size preset(up) - $(document).on("click", "#options_tabs_size_up", function(event) { + document.getElementById("options_tabs_size_up").onmousedown = function(event) { if (SelectedTheme["TabsSizeSetNumber"] < 4) { SelectedTheme["TabsSizeSetNumber"]++; ApplySizeSet(SelectedTheme["TabsSizeSetNumber"]); - ApplySizeOptionsSet(SelectedTheme["TabsSizeSetNumber"]); - SaveTheme($("#theme_list").val()); + SaveTheme(document.getElementById("theme_list").value); } - }); + } // -------------------------------TABS SCROLLBAR SIZE ADJUSTMENT---------------------------------------------------------- // change tab list scrollbar preset(down) - $(document).on("mousedown", "#options_tab_list_scrollbar_width_down", function(event) { + document.getElementById("options_tab_list_scrollbar_width_down").onmousedown = function(event) { let bod = document.getElementById("body"); var border_radius = parseInt((window.getComputedStyle(bod, null).getPropertyValue("--scrollbar_width").replace("p","").replace("x",""))); if (border_radius > 0) { border_radius--; SelectedTheme["ColorsSet"]["scrollbar_width"] = border_radius+"px"; ApplyColorsSet(SelectedTheme["ColorsSet"]); - SaveTheme($("#theme_list").val()); + SaveTheme(document.getElementById("theme_list").value); } - }); + } // change tab list scrollbar preset(up) - $(document).on("mousedown", "#options_tab_list_scrollbar_width_up", function(event) { + document.getElementById("options_tab_list_scrollbar_width_up").onmousedown = function(event) { let bod = document.getElementById("body"); var border_radius = parseInt((window.getComputedStyle(bod, null).getPropertyValue("--scrollbar_width")).replace("p","").replace("x","")); if (border_radius < 20) { border_radius++; SelectedTheme["ColorsSet"]["scrollbar_width"] = border_radius+"px"; ApplyColorsSet(SelectedTheme["ColorsSet"]); - SaveTheme($("#theme_list").val()); + SaveTheme(document.getElementById("theme_list").value); } - }); + } // change pin list scrollbar preset(down) - $(document).on("mousedown", "#options_tab_list_scrollbar_height_down", function(event) { + document.getElementById("options_tab_list_scrollbar_height_down").onmousedown = function(event) { let bod = document.getElementById("body"); var border_radius = parseInt((window.getComputedStyle(bod, null).getPropertyValue("--scrollbar_height").replace("p","").replace("x",""))); if (border_radius > 0) { border_radius--; SelectedTheme["ColorsSet"]["scrollbar_height"] = border_radius+"px"; ApplyColorsSet(SelectedTheme["ColorsSet"]); - SaveTheme($("#theme_list").val()); + SaveTheme(document.getElementById("theme_list").value); } - }); + } // change pin list scrollbar preset(up) - $(document).on("mousedown", "#options_tab_list_scrollbar_height_up", function(event) { + document.getElementById("options_tab_list_scrollbar_height_up").onmousedown = function(event) { let bod = document.getElementById("body"); var border_radius = parseInt((window.getComputedStyle(bod, null).getPropertyValue("--scrollbar_height")).replace("p","").replace("x","")); if (border_radius < 20) { border_radius++; SelectedTheme["ColorsSet"]["scrollbar_height"] = border_radius+"px"; ApplyColorsSet(SelectedTheme["ColorsSet"]); - SaveTheme($("#theme_list").val()); + SaveTheme(document.getElementById("theme_list").value); } - }); + } // ----------------------CLEAR DATA BUTTON-------------------------------------------------------------------------------- // clear data - $(document).on("click", "#options_clear_data", function(event) { + document.getElementById("options_clear_data").onclick = function(event) {if (event.which == 1) { chrome.storage.local.clear(); chrome.runtime.sendMessage({command: "reload"}); chrome.runtime.sendMessage({command: "reload_sidebar"}); - location.reload(); + setTimeout(function() { + location.reload(); + }, 300); + }} +} + +function RemoveToolbarEditEvents() { + document.querySelectorAll("#button_filter_clear").forEach(function(s){ + s.style.opacity = "0"; + }); + document.querySelectorAll(".button").forEach(function(s){ + s.removeAttribute("draggable"); }); } +function AddEditToolbarEditEvents() { + document.querySelectorAll("#button_filter_clear").forEach(function(s){ + s.style.opacity = "1"; + }); + document.querySelectorAll(".button_img").forEach(function(s){ + if (s.parentNode.id != "button_filter_type" || s.parentNode.id != "filter_search_go_prev" || s.parentNode.id != "filter_search_go_next") { + s.setAttribute("draggable", true); + s.onmousedown = function(event) { + if (event.which == 1) { + dragged_button = document.getElementById(this.parentNode.id); + } + } + s.ondragstart = function(event) { + event.dataTransfer.setData(" "," "); + event.dataTransfer.setDragImage(document.getElementById("DragImage"), 0, 0); + } + // move (flip) buttons + s.ondragenter = function(event) { + if ((dragged_button.id == "button_tools" || dragged_button.id == "button_search" || dragged_button.id == "button_groups" || dragged_button.id == "button_backup" || dragged_button.id == "button_folders") && this.parentNode.parentNode.classList.contains("toolbar_shelf")) { + return; + } + let dragged_buttonIndex = Array.from(dragged_button.parentNode.children).indexOf(dragged_button); + let Index = Array.from(this.parentNode.parentNode.children).indexOf(this.parentNode); + + if (Index <= dragged_buttonIndex) { + this.parentNode.parentNode.insertBefore(dragged_button, this.parentNode); + } else { + if (this.parentNode.nextSibling != null) { + this.parentNode.parentNode.insertBefore(dragged_button, this.parentNode.nextSibling); + } else { + this.parentNode.parentNode.appendChild(dragged_button); + } + } + } + // save toolbar + s.ondragend = function(event) { + RemoveToolbarEditEvents(); + + SelectedTheme.toolbar = document.getElementById("toolbar").innerHTML; + SelectedTheme.unused_buttons = document.getElementById("toolbar_unused_buttons").innerHTML; + SaveTheme(document.getElementById("theme_list").value); + + AddEditToolbarEditEvents(); + } + } + }); + + + document.querySelectorAll("#toolbar_main, .toolbar_shelf:not(#toolbar_search), #toolbar_unused_buttons").forEach(function(s){s.ondragenter = function(event) { + if ((dragged_button.id == "button_tools" || dragged_button.id == "button_search" || dragged_button.id == "button_groups" || dragged_button.id == "button_backup" || dragged_button.id == "button_folders") && this.classList.contains("toolbar_shelf")) { + return; + } + if (dragged_button.parentNode.id != this.id) { + this.appendChild(dragged_button); + } + + }}); +} function copyStringToClipboard(string) { function handler (event){ diff --git a/options/options_color_border_hover - Copy.svg b/options/options_color_border_hover - Copy.svg deleted file mode 100644 index fa4efc9..0000000 --- a/options/options_color_border_hover - Copy.svg +++ /dev/null @@ -1,64 +0,0 @@ - - - - - - - - image/svg+xml - - - - - - - - - - diff --git a/options/options_tabs_margin_indicator.svg b/options/options_tabs_margin_indicator.svg new file mode 100644 index 0000000..4621692 --- /dev/null +++ b/options/options_tabs_margin_indicator.svg @@ -0,0 +1,129 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + diff --git a/options/refresh.js b/options/refresh.js index 0e1f5e7..23e76a8 100644 --- a/options/refresh.js +++ b/options/refresh.js @@ -4,28 +4,46 @@ // shrink or expand theme field function RefreshFields() { - if ($("#theme_list")[0].options.length == 0) { - $("#field_theme").css({"height": "45px"}); + if (document.getElementById("theme_list").options.length == 0) { + document.getElementById("field_theme").style.height = "45px"; } else { - $("#field_theme").css({"height": ""}); + document.getElementById("field_theme").style.height = ""; } if (browserId == "F") { - $("#scrollbar_size_indicator, #scrollbar_thumb, #scrollbar_thumb_hover, #scrollbar_track").hide(); + document.querySelectorAll("#scrollbar_size_indicator, #scrollbar_thumb, #scrollbar_thumb_hover, #scrollbar_track").forEach(function(s){ + s.style.display = "none"; + }); } if (browserId == "V") { - $("#url_for_web_panel").val(chrome.runtime.getURL("sidebar.html")); - $("#url_for_web_panel").prop("readonly", true); + let WebPanelUrlBox = document.getElementById("url_for_web_panel"); + WebPanelUrlBox.value = (chrome.runtime.getURL("sidebar.html")); + WebPanelUrlBox.setAttribute("readonly", true); } else{ - $("#field_vivaldi").hide(); + document.getElementById("field_vivaldi").style.display = "none"; + } + if (document.getElementById("show_toolbar").checked) { + document.querySelectorAll("#options_available_buttons, #sample_toolbar_block, #options_reset_toolbar_button").forEach(function(s){ + s.style.display = ""; + }); + document.getElementById("field_show_toolbar").style.height = ""; + } else{ + document.querySelectorAll("#options_available_buttons, #sample_toolbar_block, #options_reset_toolbar_button").forEach(function(s){ + s.style.display = "none"; + }); + document.getElementById("field_show_toolbar").style.height = "6"; } } function RefreshGUI() { - $("#button_filter_type").addClass("url").removeClass("title"); - if ($(".button").is(".on")) { - $("#toolbar").css({ "height": 53 }); + let button_filter_type = document.getElementById("button_filter_type"); + if (button_filter_type != null) { + button_filter_type.classList.add("url"); + button_filter_type.classList.remove("title"); + } + if (document.querySelector(".on") != null) { + document.getElementById("toolbar").style.height = "53px"; } else { - $("#toolbar").css({ "height": 26 }); + document.getElementById("toolbar").style.height = "26px"; } } diff --git a/options/sample_tabs.js b/options/sample_tabs.js index c5441c1..b4593a6 100644 --- a/options/sample_tabs.js +++ b/options/sample_tabs.js @@ -4,122 +4,123 @@ function AppendSampleTabs() { // pins - AppendTab({tab: {id: 0, pinned: true}, Append: true}); - AppendTab({tab: {id: 1, pinned: true, active: false}, Append: true}); + AppendTab({id: 0, pinned: true}, false, false, false, true, false, false, false, true, false, false); + AppendTab({id: 1, pinned: true, active: false}, false, false, false, true, false, false, false, true, false, false); - AppendTab({tab: {id: 10, pinned: true, active: false}, Append: true}); - $(".pin#10").addClass("attention"); + AppendTab({id: 10, pinned: true, active: false}, false, false, false, true, false, false, false, true, false, false); + document.getElementById("10").classList.add("attention"); - // regular tabs - AppendTab({tab: {id: 2, pinned: false}, Append: true}); - $("#tab_title2")[0].textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_normal"); + AppendTab({id: 2, pinned: false}, false, false, false, true, false, false, false, true, false, true); + document.getElementById("tab_title2").textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_normal"); - AppendTab({tab: {id: 11, pinned: false}, Append: true, ParentId: "2"}); - $("#tab_title11")[0].textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_normal_hover"); - $("#tab_header11").addClass("tab_header_hover").addClass("close_show"); + AppendTab({id: 11, pinned: false}, "2", false, false, true, false, false, false, false, false, false); + document.getElementById("tab_title11").textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_normal_hover"); + document.getElementById("tab_header11").classList.add("tab_header_hover"); + document.getElementById("tab_header11").classList.add("close_show"); - AppendTab({tab: {id: 12, pinned: false}, Append: true, ParentId: "2", AdditionalClass: "selected_tab"}); - $("#tab_title12")[0].textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_normal_selected"); + AppendTab({id: 12, pinned: false}, "2", false, false, true, false, false, "selected_tab", false, false, false); + document.getElementById("tab_title12").textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_normal_selected"); - AppendTab({tab: {id: 13, pinned: false}, Append: true, ParentId: "2", AdditionalClass: "selected_tab"}); - $("#tab_title13")[0].textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_normal_selected_hover"); - $("#tab_header13").addClass("tab_header_hover").addClass("close_show"); - $("#close13").addClass("close_hover"); + AppendTab({id: 13, pinned: false}, "2", false, false, true, false, false, "selected_tab", false, false, false); + document.getElementById("tab_title13").textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_normal_selected_hover"); + document.getElementById("tab_header13").classList.add("tab_header_hover") + document.getElementById("tab_header13").classList.add("close_show"); + document.getElementById("close13").classList.add("close_hover"); // regular active tabs - AppendTab({tab: {id: 3, pinned: false}, Append: true, ParentId: "2", AdditionalClass: "active_tab"}); - $("#tab_title3")[0].textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_active"); + AppendTab({id: 3, pinned: false}, "2", false, false, true, false, false, "active_tab", false, false, false); + document.getElementById("tab_title3").textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_active"); - AppendTab({tab: {id: 15, pinned: false}, Append: true, ParentId: "2", AdditionalClass: "active_tab"}); - $("#tab_title15")[0].textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_active_hover"); - $("#tab_header15").addClass("tab_header_hover"); + AppendTab({id: 15, pinned: false}, "2", false, false, true, false, false, "active_tab", false, false, false); + document.getElementById("tab_title15").textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_active_hover"); + document.getElementById("tab_header15").classList.add("tab_header_hover"); - AppendTab({tab: {id: 14, pinned: false}, Append: true, ParentId: "2", AdditionalClass: "c selected_tab active_tab"}); - $("#tab_title14")[0].textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_active_selected"); + AppendTab({id: 14, pinned: false}, "2", false, false, true, false, false, "c selected_tab active_tab", false, false, false); + document.getElementById("tab_title14").textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_active_selected"); - AppendTab({tab: {id: 16, pinned: false}, Append: true, ParentId: "2", AdditionalClass: "c selected_tab active_tab"}); - $("#tab_title16")[0].textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_active_selected_hover"); - $("#tab_header16").addClass("tab_header_hover"); - $("#exp16").addClass("hover"); + AppendTab({id: 16, pinned: false}, "2", false, false, true, false, false, "c selected_tab active_tab", false, false, false); + document.getElementById("tab_title16").textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_active_selected_hover"); + document.getElementById("tab_header16").classList.add("tab_header_hover"); + document.getElementById("exp16").classList.add("hover"); // discarded tabs - AppendTab({tab: {id: 5, pinned: false, discarded: true}, Append: true}); - $("#tab_title5")[0].textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_discarded"); + AppendTab({id: 5, pinned: false, discarded: true}, false, false, false, true, false, false, false, false, false, false); + document.getElementById("tab_title5").textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_discarded"); - AppendTab({tab: {id: 17, pinned: false, discarded: true}, Append: true, ParentId: "5"}); - $("#tab_title17")[0].textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_discarded_hover"); - $("#tab_header17").addClass("tab_header_hover"); + AppendTab({id: 17, pinned: false, discarded: true}, "5", false, false, true, false, false, false, false, false, false); + document.getElementById("tab_title17").textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_discarded_hover"); + document.getElementById("tab_header17").classList.add("tab_header_hover"); - AppendTab({tab: {id: 19, pinned: false, discarded: true}, Append: true, ParentId: "5", AdditionalClass: "selected_tab"}); - $("#tab_title19")[0].textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_discarded_selected"); + AppendTab({id: 19, pinned: false, discarded: true}, "5", false, false, true, false, false, "selected_tab", false, false, false); + document.getElementById("tab_title19").textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_discarded_selected"); - AppendTab({tab: {id: 20, pinned: false, discarded: true}, Append: true, ParentId: "5", AdditionalClass: "selected_tab"}); - $("#tab_title20")[0].textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_discarded_selected_hover"); - $("#tab_header20").addClass("tab_header_hover"); + AppendTab({id: 20, pinned: false, discarded: true}, "5", false, false, true, false, false, "selected_tab", false, false, false); + document.getElementById("tab_title20").textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_discarded_selected_hover"); + document.getElementById("tab_header20").classList.add("tab_header_hover"); // search result - AppendTab({tab: {id: 6, pinned: false}, Append: true, AdditionalClass: "filtered"}); - $("#tab_title6")[0].textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_search_result"); + AppendTab({id: 6, pinned: false}, false, false, false, true, false, false, "filtered", false, false, false); + document.getElementById("tab_title6").textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_search_result"); - AppendTab({tab: {id: 21, pinned: false}, Append: true, ParentId: "6", AdditionalClass: "filtered"}); - $("#tab_title21")[0].textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_search_result_hover"); - $("#tab_header21").addClass("tab_header_hover"); + AppendTab({id: 21, pinned: false}, "6", false, false, true, false, false, "filtered", false, false, false); + document.getElementById("tab_title21").textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_search_result_hover"); + document.getElementById("tab_header21").classList.add("tab_header_hover"); - AppendTab({tab: {id: 22, pinned: false}, Append: true, ParentId: "6", AdditionalClass: "filtered active_tab"}); - $("#tab_title22")[0].textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_search_result_active"); + AppendTab({id: 22, pinned: false}, "6", false, false, true, false, false, "filtered active_tab", false, false, false); + document.getElementById("tab_title22").textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_search_result_active"); - AppendTab({tab: {id: 23, pinned: false}, Append: true, ParentId: "6", AdditionalClass: "filtered active_tab"}); - $("#tab_title23")[0].textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_search_result_active_hover"); - $("#tab_header23").addClass("tab_header_hover"); + AppendTab({id: 23, pinned: false}, "6", false, false, true, false, false, "filtered active_tab", false, false, false); + document.getElementById("tab_title23").textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_search_result_active_hover"); + document.getElementById("tab_header23").classList.add("tab_header_hover"); // search result selected - AppendTab({tab: {id: 8, pinned: false}, Append: true, ParentId: "6", AdditionalClass: "selected_tab filtered"}); - $("#tab_title8")[0].textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_search_result_selected"); + AppendTab({id: 8, pinned: false}, "6", false, false, true, false, false, "selected_tab filtered", false, false, false); + document.getElementById("tab_title8").textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_search_result_selected"); - AppendTab({tab: {id: 18, pinned: false}, Append: true, ParentId: "6", AdditionalClass: "selected_tab filtered"}); - $("#tab_title18")[0].textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_search_result_selected_hover"); - $("#tab_header18").addClass("tab_header_hover"); + AppendTab({id: 18, pinned: false}, "6", false, false, true, false, false, "selected_tab filtered", false, false, false); + document.getElementById("tab_title18").textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_search_result_selected_hover"); + document.getElementById("tab_header18").classList.add("tab_header_hover"); - AppendTab({tab: {id: 25, pinned: false}, Append: true, ParentId: "6", AdditionalClass: "selected_tab filtered active_tab"}); - $("#tab_title25")[0].textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_search_result_selected_active"); + AppendTab({id: 25, pinned: false}, "6", false, false, true, false, false, "selected_tab filtered active_tab", false, false, false); + document.getElementById("tab_title25").textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_search_result_selected_active"); - AppendTab({tab: {id: 26, pinned: false}, Append: true, ParentId: "6", AdditionalClass: "selected_tab filtered active_tab"}); - $("#tab_title26")[0].textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_search_result_selected_active_hover"); - $("#tab_header26").addClass("tab_header_hover"); + AppendTab({id: 26, pinned: false}, "6", false, false, true, false, false, "selected_tab filtered active_tab", false, false, false); + document.getElementById("tab_title26").textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_search_result_selected_active_hover"); + document.getElementById("tab_header26").classList.add("tab_header_hover"); // search result highlighted - AppendTab({tab: {id: 30, pinned: false}, Append: true, AdditionalClass: "filtered highlighted_search"}); - $("#tab_title30")[0].textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_search_result_highlighted"); + AppendTab({id: 30, pinned: false}, false, false, false, true, false, false, "filtered highlighted_search", false, false, false); + document.getElementById("tab_title30").textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_search_result_highlighted"); - AppendTab({tab: {id: 31, pinned: false}, Append: true, ParentId: "30", AdditionalClass: "filtered highlighted_search"}); - $("#tab_title31")[0].textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_search_result_highlighted_hover"); - $("#tab_header31").addClass("tab_header_hover"); + AppendTab({id: 31, pinned: false}, "30", false, false, true, false, false, "filtered highlighted_search", false, false, false); + document.getElementById("tab_title31").textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_search_result_highlighted_hover"); + document.getElementById("tab_header31").classList.add("tab_header_hover"); - AppendTab({tab: {id: 32, pinned: false}, Append: true, ParentId: "30", AdditionalClass: "filtered highlighted_search active_tab"}); - $("#tab_title32")[0].textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_search_result_highlighted_active"); + AppendTab({id: 32, pinned: false}, "30", false, false, true, false, false, "filtered highlighted_search active_tab", false, false, false); + document.getElementById("tab_title32").textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_search_result_highlighted_active"); - AppendTab({tab: {id: 33, pinned: false}, Append: true, ParentId: "30", AdditionalClass: "filtered highlighted_search active_tab"}); - $("#tab_title33")[0].textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_search_result_highlighted_active_hover"); - $("#tab_header33").addClass("tab_header_hover"); + AppendTab({id: 33, pinned: false}, "30", false, false, true, false, false, "filtered highlighted_search active_tab", false, false, false); + document.getElementById("tab_title33").textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_search_result_highlighted_active_hover"); + document.getElementById("tab_header33").classList.add("tab_header_hover"); - AppendTab({tab: {id: 34, pinned: false}, Append: true, ParentId: "30", AdditionalClass: "selected_tab filtered highlighted_search"}); - $("#tab_title34")[0].textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_search_result_highlighted_selected"); + AppendTab({id: 34, pinned: false}, "30", false, false, true, false, false, "selected_tab filtered highlighted_search", false, false, false); + document.getElementById("tab_title34").textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_search_result_highlighted_selected"); - AppendTab({tab: {id: 35, pinned: false}, Append: true, ParentId: "30", AdditionalClass: "selected_tab filtered highlighted_search"}); - $("#tab_title35")[0].textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_search_result_highlighted_selected_hover"); - $("#tab_header35").addClass("tab_header_hover"); + AppendTab({id: 35, pinned: false}, "30", false, false, true, false, false, "selected_tab filtered highlighted_search", false, false, false); + document.getElementById("tab_title35").textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_search_result_highlighted_selected_hover"); + document.getElementById("tab_header35").classList.add("tab_header_hover"); - AppendTab({tab: {id: 36, pinned: false}, Append: true, ParentId: "30", AdditionalClass: "selected_tab filtered highlighted_search active_tab"}); - $("#tab_title36")[0].textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_search_result_highlighted_selected_active"); + AppendTab({id: 36, pinned: false}, "30", false, false, true, false, false, "selected_tab filtered highlighted_search active_tab", false, false, false); + document.getElementById("tab_title36").textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_search_result_highlighted_selected_active"); - AppendTab({tab: {id: 37, pinned: false}, Append: true, ParentId: "30", AdditionalClass: "selected_tab filtered highlighted_search active_tab"}); - $("#tab_title37")[0].textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_search_result_highlighted_selected_active_hover"); - $("#tab_header37").addClass("tab_header_hover"); - - $("#_tab_list").addClass("active_group"); + AppendTab({id: 37, pinned: false}, "30", false, false, true, false, false, "selected_tab filtered highlighted_search active_tab", false, false, false); + document.getElementById("tab_title37").textContent = chrome.i18n.getMessage("options_theme_tabs_sample_text_search_result_highlighted_selected_active_hover"); + document.getElementById("tab_header37").classList.add("tab_header_hover"); + + document.getElementById("_tab_list").classList.add("active_group"); } \ No newline at end of file diff --git a/options/theme.js b/options/theme.js index e4c977e..e31faed 100644 --- a/options/theme.js +++ b/options/theme.js @@ -2,7 +2,12 @@ // Use of this source code is governed by a Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0) license // that can be found at https://creativecommons.org/licenses/by-nc-nd/4.0/ -function LoadTheme(themeName) { +function LoadTheme(themeName, reloadSidebar) { + + document.querySelectorAll(".theme_buttons").forEach(function(s){ + s.disabled = true; + }); + chrome.storage.local.get(null, function(items) { if (items.themes[themeName]) { SelectedTheme = Object.assign({}, items.themes[themeName]); @@ -12,22 +17,52 @@ function LoadTheme(themeName) { current_theme = ""; } setTimeout(function() { - $("#new_theme_name")[0].value = themeName; + document.getElementById("new_theme_name").value = themeName; setTimeout(function() { + + SetToolbarEvents(true, false, false, ""); + RemoveToolbarEditEvents(); + ApplySizeSet(SelectedTheme["TabsSizeSetNumber"]); ApplyColorsSet(SelectedTheme["ColorsSet"]); - ApplySizeOptionsSet(SelectedTheme["TabsSizeSetNumber"]); - $("#toolbar").html(SelectedTheme.toolbar); - $("#toolbar_unused_buttons").html(SelectedTheme.unused_buttons); + + document.getElementById("_gtetab_list").style.color = ""; + document.getElementById("_gtetab_list2").style.color = ""; + + document.getElementById("toolbar").innerHTML = SelectedTheme.toolbar; + document.getElementById("toolbar_unused_buttons").innerHTML = SelectedTheme.unused_buttons; + if (browserId == "F") { - $(".button#button_load_bak1, .button#button_load_bak2, .button#button_load_bak3").remove(); + document.querySelectorAll("#button_load_bak1, #button_load_bak2, #button_load_bak3").forEach(function(s){ + s.parentNode.removeChild(s); + }); } - SelectedTheme.ToolbarShow = $("#show_toolbar")[0].checked = SelectedTheme.ToolbarShow; - $("#field_show_toolbar").css({"height": $("#show_toolbar")[0].checked ? "" : "6"}); - SelectedTheme.ToolbarShow ? $("#options_available_buttons, #toolbar, #toolbar_colors").show() : $("#options_available_buttons, #toolbar, #toolbar_colors").hide(); - $(".on").removeClass("on"); + + document.getElementById("show_toolbar").checked = SelectedTheme.ToolbarShow; + + if (SelectedTheme["TabsMargins"]) { + document.getElementById("tabs_margin_spacing")[SelectedTheme["TabsMargins"]].checked = true; + ApplyTabsMargins(SelectedTheme["TabsMargins"]); + } else { + document.getElementById("tabs_margin_spacing")["2"].checked = true; + } + + document.querySelectorAll(".on").forEach(function(s){ + s.classList.remove("on"); + }); + + SetToolbarEvents(false, false, true, "click"); + AddEditToolbarEditEvents(); + RefreshFields(); RefreshGUI(); - chrome.runtime.sendMessage({command: "reload_theme", themeName: "theme"+themeName}); + if (reloadSidebar) { + chrome.runtime.sendMessage({command: "reload_theme", themeName: "theme"+themeName}); + } + + document.querySelectorAll(".theme_buttons").forEach(function(s){ + s.disabled = false; + }); + }, 200); }, 200); }); @@ -42,45 +77,72 @@ function SaveTheme(themeName) { }); } function AddNewTheme() { - if (themes.indexOf($("#new_theme_name")[0].value) != -1) { - alert(chrome.i18n.getMessage("options_there_is_a_theme_with_this_name")); - return; - } - if ($("#new_theme_name")[0].value == "") { + + let ThemeList = document.getElementById("theme_list"); + let ThemeNameBox = document.getElementById("new_theme_name"); + let NewName = ThemeNameBox.value; + + if (ThemeNameBox.value == "") { alert(chrome.i18n.getMessage("options_theme_name_cannot_be_empty")); return; } - $("#toolbar").html(DefaultToolbar); + + document.getElementById("toolbar").innerHTML = DefaultToolbar; + SelectedTheme = Object.assign({}, DefaultTheme); SelectedTheme["ColorsSet"] = {}; DefaultTheme["ColorsSet"] = {}; - themes.push($("#new_theme_name")[0].value); - var t_list = document.getElementById("theme_list"); - var theme_name = document.createElement("option"); - theme_name.value = $("#new_theme_name")[0].value; - theme_name.text = theme_name.value; - t_list.add(theme_name); - $("#theme_list")[0].selectedIndex = $("#theme_list")[0].options.length-1; - SaveTheme(theme_name.value); + + if (themes.indexOf(NewName) != -1) { + while (themes.indexOf(NewName) != -1) { + let matched = NewName.match(/\(\d+\)+/); + if (matched != null && matched.length > 0) { + NewName = NewName.replace(matched[0], ("(" + (parseInt(matched[0].match(/\d+/)[0]) + 1 ) + ")") ); + } else { + NewName = NewName + "(1)"; + } + } + } + + + ThemeNameBox.value = NewName; + SelectedTheme["theme_name"] = NewName; + + themes.push(NewName); + + let ThemeNameOption = document.createElement("option"); + + ThemeNameOption.value = NewName; + ThemeNameOption.text = NewName; + + ThemeList.add(ThemeNameOption); + ThemeList.selectedIndex = ThemeList.options.length-1; + + SaveTheme(NewName); setTimeout(function() { - LoadTheme(theme_name.value); - }, 500); - chrome.storage.local.set({current_theme: $("#theme_list").val()}); + LoadTheme(NewName, true); + }, 50); + + chrome.storage.local.set({current_theme: NewName}); RefreshFields(); } function DeleteSelectedTheme() { chrome.storage.local.get(null, function(items) { let LSthemes = items.themes ? Object.assign({}, items.themes) : {}; - themes.splice(themes.indexOf($("#theme_list").val()), 1); + + let ThemeList = document.getElementById("theme_list"); + + themes.splice(ThemeList.selectedIndex, 1); if (LSthemes[current_theme]) { delete LSthemes[current_theme]; } chrome.storage.local.set({themes: LSthemes}); - var x = document.getElementById("theme_list"); - x.remove(x.selectedIndex); - current_theme = ($("#theme_list")[0].options.length > 0) ? $("#theme_list").val() : "Default"; + + ThemeList.remove(ThemeList.selectedIndex); + + current_theme = (ThemeList.options.length > 0) ? ThemeList.value : "Default"; chrome.storage.local.set({current_theme: current_theme}); - if ($("#theme_list")[0].options.length == 0) { + if (ThemeList.options.length == 0) { SelectedTheme = Object.assign({}, DefaultTheme); SelectedTheme["ColorsSet"] = {}; chrome.storage.local.set({themes: {}}); @@ -88,29 +150,34 @@ function DeleteSelectedTheme() { chrome.runtime.sendMessage({command: "reload_theme", themeName: ""}); }, 500); } - LoadTheme(current_theme); + LoadTheme(current_theme, true); RefreshFields(); }); } function RenameSelectedTheme() { - if (themes.indexOf($("#new_theme_name")[0].value) != -1) { + + let ThemeNameBox = document.getElementById("new_theme_name"); + + if (themes.indexOf(ThemeNameBox.value) != -1) { alert(chrome.i18n.getMessage("options_there_is_a_theme_with_this_name")); return; } - if ($("#new_theme_name")[0].value == "") { + if (ThemeNameBox.value == "") { alert(chrome.i18n.getMessage("options_theme_name_cannot_be_empty")); return; } chrome.storage.local.get(null, function(items) { let LSthemes = items.themes ? Object.assign({}, items.themes) : {}; - SelectedTheme["theme_name"] = $("#new_theme_name")[0].value; - let t_list = document.getElementById("theme_list"); - t_list.options[t_list.selectedIndex].value = t_list.options[t_list.selectedIndex].text = SelectedTheme["theme_name"]; - LSthemes[SelectedTheme["theme_name"]] = SelectedTheme; + SelectedTheme["theme_name"] = ThemeNameBox.value; + let ThemeList = document.getElementById("theme_list"); + ThemeList.options[ThemeList.selectedIndex].value = ThemeNameBox.value; + ThemeList.options[ThemeList.selectedIndex].text = ThemeNameBox.value; + LSthemes[ThemeNameBox.value] = SelectedTheme; if (LSthemes[current_theme]) { delete LSthemes[current_theme]; } - current_theme = SelectedTheme["theme_name"]; + current_theme = ThemeNameBox.value; + themes[ThemeList.selectedIndex] = ThemeNameBox.value; chrome.storage.local.set({themes: LSthemes}); chrome.storage.local.set({current_theme: current_theme}); }); @@ -122,7 +189,7 @@ function ImportTheme() { fr.readAsText(file.files[0]); fr.onload = function() { var data = fr.result; - file.remove(); + file.parentNode.removeChild(file); var themeObj = JSON.parse(data); if (themeObj.theme_version > DefaultTheme["theme_version"]) { alert(chrome.i18n.getMessage("options_loaded_theme_newer_version")); @@ -146,38 +213,39 @@ function ImportTheme() { if (themeObj.theme_version == 2) { SelectedTheme["unused_buttons"] = themeObj["unused_buttons"]; } + if (themeObj.theme_version == 3) { + SelectedTheme["TabsMargins"] = themeObj["TabsMargins"]; + } if (themes.indexOf(themeObj.theme_name) == -1) { SelectedTheme["theme_name"] = themeObj.theme_name; } else { - SelectedTheme["theme_name"] = themeObj.theme_name + "(1)"; + let NewName = themeObj.theme_name; + while (themes.indexOf(NewName) != -1) { + let matched = NewName.match(/\(\d+\)+/); + if (matched != null && matched.length > 0) { + NewName = NewName.replace(matched[0], ("(" + (parseInt(matched[0].match(/\d+/)[0]) + 1 ) + ")") ); + } else { + NewName = NewName + "(1)"; + } + } + SelectedTheme["theme_name"] = NewName; } themes.push(SelectedTheme["theme_name"]); SaveTheme(SelectedTheme["theme_name"]); - var t_list = document.getElementById("theme_list"); + var ThemeList = document.getElementById("theme_list"); var theme_name = document.createElement("option"); theme_name.value = SelectedTheme["theme_name"]; theme_name.text = theme_name.value; - t_list.add(theme_name); - $("#theme_list")[0].selectedIndex = $("#theme_list")[0].options.length-1; + ThemeList.add(theme_name); + ThemeList.selectedIndex = ThemeList.options.length-1; current_theme = SelectedTheme["theme_name"]; - $("#new_theme_name")[0].value = current_theme; + document.createElement("new_theme_name").value = current_theme; setTimeout(function() { - LoadTheme(current_theme); + LoadTheme(current_theme, true); }, 500); RefreshFields(); DefaultTheme["ColorsSet"] = {}; chrome.storage.local.set({current_theme: current_theme}); } } -} -function ApplySizeOptionsSet(size){ - for (let si = 0; si < document.styleSheets.length; si++) { - if ((document.styleSheets[si].ownerNode.id).match("size_settings") != null) { - if (document.styleSheets[si].ownerNode.id == "size_settings_"+size) { - document.styleSheets.item(si).disabled = false; - } else { - document.styleSheets.item(si).disabled = true; - } - } - } } \ No newline at end of file diff --git a/options/theme_size_settings_0.css b/options/theme_size_settings_0.css deleted file mode 100644 index ae48b6f..0000000 --- a/options/theme_size_settings_0.css +++ /dev/null @@ -1,168 +0,0 @@ -/* OPTIONS IMAGES */ -.font_color {z-index: 1000; position: absolute; display: float; height: 20px; width: 20px; background-size: 20px 20px; background-image: url(../options/options_font_color.svg);} -.font_color:hover {background-image: url(../options/options_font_color_hover.svg);} -.font_weight_normal {z-index: 1000; position: absolute; display: float; height: 20px; width: 20px; background-size: 20px 20px; background-image: url(../options/options_font_style_normal.svg);} -.font_weight_normal:hover {background-image: url(../options/options_font_style_normal_hover.svg);} -.font_weight_bold {z-index: 1000; position: absolute; display: float; height: 20px; width: 20px; background-size: 20px 20px; background-image: url(../options/options_font_weight_bold.svg);} -.font_weight_bold:hover {background-image: url(../options/options_font_weight_bold_hover.svg);} -.font_style_normal {z-index: 1000; position: absolute; display: float; height: 20px; width: 20px; background-size: 20px 20px; background-image: url(../options/options_font_style_normal.svg);} -.font_style_normal:hover {background-image: url(../options/options_font_style_normal_hover.svg);} -.font_style_italic {z-index: 1000; position: absolute; display: float; height: 20px; width: 20px; background-size: 20px 20px; background-image: url(../options/options_font_style_italic.svg);} -.font_style_italic:hover {background-image: url(../options/options_font_style_italic_hover.svg);} - -.color_toolbar_icon {z-index: 10000; position: absolute; display: block; height: 20px; width: 20px; background-size: 20px 20px; background-image: url(../options/options_color_toolbar_icon.svg);} -.color_toolbar_icon:hover {background-image: url(../options/options_color_toolbar_icon_hover.svg);} - -.color_bucket {z-index: 10000; position: absolute; display: float; height: 20px; width: 20px; background-size: 20px 20px; background-image: url(../options/options_color_bucket.svg);} -.color_bucket:hover {background-image: url(../options/options_color_bucket_hover.svg);} - -.color_brush {z-index: 10000; position: absolute; display: float; height: 20px; width: 20px; background-size: 20px 20px; background-image: url(../options/options_color_brush.svg);} -.color_brush:hover {background-image: url(../options/options_color_brush_hover.svg);} - -.color_border {z-index: 10000; position: absolute; display: float; height: 20px; width: 20px; background-size: 20px 20px; background-image: url(../options/options_color_border.svg);} -.color_border:hover {background-image: url(../options/options_color_border_hover.svg);} - -.color_x {z-index: 10000; position: absolute; display: float; height: 20px; width: 20px; background-size: 20px 20px; background-image: url(../options/options_color_x.svg);} -.color_x:hover {background-image: url(../options/options_color_x_hover.svg);} - -.options_button_minus {z-index: 10000; display: float; position: absolute; top: 5px; left: 6px; height: 20px; width: 20px; background-size: 20px 20px; background-image: url(../options/options_scale_minus.svg);} -.options_button_minus:hover {background-image: url(../options/options_scale_minus_hover.svg);} -.options_button_plus {z-index: 10000; display: float; position: absolute; top: 5px; left: 54px; height: 20px; width: 20px; background-size: 20px 20px; background-image: url(../options/options_scale_plus.svg);} -.options_button_plus:hover {background-image: url(../options/options_scale_plus_hover.svg);} - -@keyframes hover_blinking { - 0% {background-color: transparent;} - 100% {background-color: blue;} -} -.hover_blinking { - animation: hover_blinking 1s infinite; -} - -@keyframes hover_border_blinking { - 0% {border: 1px solid transparent;} - 100% {border: 1px solid blue;} -} -.hover_border_blinking { - animation: hover_border_blinking 1s infinite; -} - -/* MAIN TOOLBAR */ -#toolbar_background { top: 0px; left: 307px; } -#toolbar_border_bottom { top: 0px; left: 328px; } - -#button_icons { top: 0px; left: 59px; } -#button_icons_hover { top: 0px; left: 80px; } - -#button_background { top: 0px; left: 4px; } -#button_hover_background { top: 0px; left: 25px; } - -#button_border { top: 0px; left: 115px; } -#button_hover_border { top: 0px; left: 136px; } - -#filter_box_font { top: 0px; left: 175px; } -#filter_clear_icon { top: 0px; left: 238px; } -#filter_box_background { top: 0px; left: 196px; } -#filter_box_border { top: 0px; left: 217px; } - - -/* BIG OPTIONS BUTTONS */ -#options_tabs_indentation_indicator { z-index: 3000; display: float; position: absolute; top: 25px; left: 550px; height: 30px; width: 80px; background-size: 80px 30px; background-image: url(../options/options_tabs_indentation_indicator.svg);} -#options_tabs_roundness_indicator { z-index: 3000; display: float; position: absolute; top: 25px; left: 640px; height: 30px; width: 80px; background-size: 80px 30px; background-image: url(../options/options_tabs_roundness_indicator.svg);} -#options_tabs_size_indicator { z-index: 3000; display: float; position: absolute; top: 25px; left: 730px; height: 30px; width: 80px; background-size: 80px 30px; background-image: url(../options/options_tabs_size_indicator.svg);} - -/* SCROLLBAR RESIZE */ -#scrollbar_size_indicator {z-index: 3000; display: float; position: absolute; top: 20px; left: 335px; height: 80px; width: 80px; background-size: 80px 80px; background-image: url(../options/options_scrollbar_size_indicator.svg); } -#options_tab_list_scrollbar_width_down { left: 3px; top: 30px; } -#options_tab_list_scrollbar_width_up { left: 57px; top: 30px; } -#options_tab_list_scrollbar_height_up { left: 30px; top: 3px; } -#options_tab_list_scrollbar_height_down { left: 30px; top: 57px; } - - -/* PIN LIST AND SCROLLBAR */ -#pin_list { position: absolute; height: calc(var(--scrollbar_height) + var(--pin_height)); width: 788px; top: 30px; left: 20px;} - -#pin_list_scrollbar { position: absolute; height: var(--scrollbar_height); width: 790px; top: calc(var(--pin_height) + 31px); left: 20px; z-index: 1000; background-color: var(--scrollbar_track); } -#pin_list_scrollbar_thumb { position: relative; height: 100%; width: 100px; top: 0px; left: 0px; z-index: 1200; background-color: var(--scrollbar_thumb); } -#pin_list_scrollbar_thumb:hover { background-color: var(--scrollbar_thumb_hover); } - - - -/* PINS */ -#pin_list_options_block {z-index: 2000; position:absolute; width: 500px; height: var(--pin_height); top: 30px; left: 20px; margin: 0; /* background:rgba(0,0,255,0.1); */ } -#pin_list_background { top: 1px; left: 187px; } -#pin_list_border_bottom { top: 1px; left: 164px; } - - -/* ATTENTION PIN */ -#attention_background { top: 1px; left: 72px; } -#attention_border { top: 1px; left: 93px; } - - - -/* TAB LIST AND SCROLLBAR */ -#tab_list { position: absolute; height: 800px; width: calc(770px - var(--scrollbar_width)); top: calc(var(--scrollbar_height) + var(--pin_height) + 32px); left: 40px; z-index: 1000 } - -#group_scrollbar { position: absolute; height: 800px; width: var(--scrollbar_width); top: calc(var(--scrollbar_height) + var(--pin_height) + 32px); left: calc(810px - var(--scrollbar_width)); z-index: 1000; background-color: var(--scrollbar_track); } -#group_scrollbar_thumb { position: relative; height: 200px; width: 100%; top: 140px; left: 0px; z-index: 1000; background-color: var(--scrollbar_thumb); } -#group_scrollbar_thumb:hover { background-color: var(--scrollbar_thumb_hover); } -#scrollbar_thumb { position: absolute; top: 370px; left: 790px; } -#scrollbar_thumb_hover { position: absolute; top: 390px; left: 790px; } -#scrollbar_track { position: absolute; top: 410px; left: 790px; } - -#Tabs { - --row_image_size: 16px 16px; -} -/* TABS */ -#tabs_options_block {z-index: 2000; position:absolute; width: 740px; height: auto; top: calc(var(--scrollbar_height) + var(--pin_height) + 32px); left: 50px; margin: 0; /* background:rgba(0,255,0,0.5); */ } - -.tab_color_options_row {z-index: 2000; position:relative; width: 740px; height: 18px; /* background:rgba(255,0,0,0.1); */ } -.tab_color_options_row>.color_border {top: 1px; left: 659px; background-size: var(--row_image_size);} -.tab_color_options_row>.color_bucket {top: 1px; left: 680px; background-size: var(--row_image_size);} -.tab_color_options_row>.font_color {top: 1px; left: 509px; background-size: var(--row_image_size);} -.tab_color_options_row>.font_weight_normal {top: 1px; left: 538px; background-size: var(--row_image_size);} -.tab_color_options_row>.font_weight_bold {top: 1px; left: 559px; background-size: var(--row_image_size);} -.tab_color_options_row>.font_style_normal {top: 1px; left: 588px; background-size: var(--row_image_size);} -.tab_color_options_row>.font_style_italic {top: 1px; left: 609px; background-size: var(--row_image_size);} - - -/* DRAG AND DROP INDICATOR */ -#dd19 { display: inline-block; border-bottom: 2px solid var(--drag_indicator); } -#drag_indicator { top: 8px; left: 350px; background-size: var(--row_image_size);} - - -/* CLOSE TAB BUTTON OPTIONS */ -#close_x { top: 0px; left: calc(753px - var(--scrollbar_width)); background-size: var(--row_image_size);} -#close_hover_x { top: -14px; left: calc(753px - var(--scrollbar_width)); background-size: var(--row_image_size);} -#close_hover_border { top: 2px; left: calc(753px - var(--scrollbar_width)); background-size: var(--row_image_size);} -#close_hover_background { top: 18px; left: calc(753px - var(--scrollbar_width)); background-size: var(--row_image_size);} - - -/* CLOSE TAB BUTTON OPTIONS */ -#expand_hover_background { top: 1px; left: calc(var(--children_padding_left) - 18px); background-size: var(--row_image_size);} -#expand_closed_background { top: 1px; left: calc(var(--children_padding_left) - 18px); background-size: var(--row_image_size);} -#expand_open_background { top: 1px; left: -12px; background-size: var(--row_image_size);} - - -#tab_list_background { top: 835px; left: 50px; } - - - -#toolbar_groups_block { position: absolute; left: 20px; top: calc(var(--scrollbar_height) + var(--pin_height) + 32px); width: 19px; height: 800px; background-color: var(--group_list_background); border-right: 1px solid var(--group_list_borders); overflow: visible; } -#_gtetab_list { width: 200px; height: 20px; } -#_gtetab_list2 { width: 200px; height: 20px; } -#_tab_list2:hover { background-color: var(--group_list_button_hover_background); } - -#group_list_background { top: 835px; left: 20px; } -#group_list_borders { top: 631px; left: 20px; } -#group_list_default_font_color { top: 652px; left: 20px; } -#group_list_button_hover_background { top: 610px; left: 20px; } - - -/* MENU */ -#tabs_menu_border { top: 59px; left: 80px; } -#tabs_menu_background { top: 59px; left: 102px; } -#tabs_menu_font { top: 36px; left: 102px; } -#tabs_menu_hover_border { top: 14px; left: 80px; } -#tabs_menu_hover_background { top: 14px; left: 102px; } -#tabs_menu_separator { top: 36px; left: 80px; } - diff --git a/options/theme_size_settings_1.css b/options/theme_size_settings_1.css deleted file mode 100644 index b18a0f4..0000000 --- a/options/theme_size_settings_1.css +++ /dev/null @@ -1,168 +0,0 @@ -/* OPTIONS IMAGES */ -.font_color {z-index: 1000; position: absolute; display: float; height: 20px; width: 20px; background-size: 20px 20px; background-image: url(../options/options_font_color.svg);} -.font_color:hover {background-image: url(../options/options_font_color_hover.svg);} -.font_weight_normal {z-index: 1000; position: absolute; display: float; height: 20px; width: 20px; background-size: 20px 20px; background-image: url(../options/options_font_style_normal.svg);} -.font_weight_normal:hover {background-image: url(../options/options_font_style_normal_hover.svg);} -.font_weight_bold {z-index: 1000; position: absolute; display: float; height: 20px; width: 20px; background-size: 20px 20px; background-image: url(../options/options_font_weight_bold.svg);} -.font_weight_bold:hover {background-image: url(../options/options_font_weight_bold_hover.svg);} -.font_style_normal {z-index: 1000; position: absolute; display: float; height: 20px; width: 20px; background-size: 20px 20px; background-image: url(../options/options_font_style_normal.svg);} -.font_style_normal:hover {background-image: url(../options/options_font_style_normal_hover.svg);} -.font_style_italic {z-index: 1000; position: absolute; display: float; height: 20px; width: 20px; background-size: 20px 20px; background-image: url(../options/options_font_style_italic.svg);} -.font_style_italic:hover {background-image: url(../options/options_font_style_italic_hover.svg);} - -.color_toolbar_icon {z-index: 10000; position: absolute; display: block; height: 20px; width: 20px; background-size: 20px 20px; background-image: url(../options/options_color_toolbar_icon.svg);} -.color_toolbar_icon:hover {background-image: url(../options/options_color_toolbar_icon_hover.svg);} - -.color_bucket {z-index: 10000; position: absolute; display: float; height: 20px; width: 20px; background-size: 20px 20px; background-image: url(../options/options_color_bucket.svg);} -.color_bucket:hover {background-image: url(../options/options_color_bucket_hover.svg);} - -.color_brush {z-index: 10000; position: absolute; display: float; height: 20px; width: 20px; background-size: 20px 20px; background-image: url(../options/options_color_brush.svg);} -.color_brush:hover {background-image: url(../options/options_color_brush_hover.svg);} - -.color_border {z-index: 10000; position: absolute; display: float; height: 20px; width: 20px; background-size: 20px 20px; background-image: url(../options/options_color_border.svg);} -.color_border:hover {background-image: url(../options/options_color_border_hover.svg);} - -.color_x {z-index: 10000; position: absolute; display: float; height: 20px; width: 20px; background-size: 20px 20px; background-image: url(../options/options_color_x.svg);} -.color_x:hover {background-image: url(../options/options_color_x_hover.svg);} - -.options_button_minus {z-index: 10000; display: float; position: absolute; top: 5px; left: 6px; height: 20px; width: 20px; background-size: 20px 20px; background-image: url(../options/options_scale_minus.svg);} -.options_button_minus:hover {background-image: url(../options/options_scale_minus_hover.svg);} -.options_button_plus {z-index: 10000; display: float; position: absolute; top: 5px; left: 54px; height: 20px; width: 20px; background-size: 20px 20px; background-image: url(../options/options_scale_plus.svg);} -.options_button_plus:hover {background-image: url(../options/options_scale_plus_hover.svg);} - -@keyframes hover_blinking { - 0% {background-color: transparent;} - 100% {background-color: blue;} -} -.hover_blinking { - animation: hover_blinking 1s infinite; -} - -@keyframes hover_border_blinking { - 0% {border: 1px solid transparent;} - 100% {border: 1px solid blue;} -} -.hover_border_blinking { - animation: hover_border_blinking 1s infinite; -} - -/* MAIN TOOLBAR */ -#toolbar_background { top: 0px; left: 307px; } -#toolbar_border_bottom { top: 0px; left: 328px; } - -#button_icons { top: 0px; left: 59px; } -#button_icons_hover { top: 0px; left: 80px; } - -#button_background { top: 0px; left: 4px; } -#button_hover_background { top: 0px; left: 25px; } - -#button_border { top: 0px; left: 115px; } -#button_hover_border { top: 0px; left: 136px; } - -#filter_box_font { top: 0px; left: 175px; } -#filter_clear_icon { top: 0px; left: 238px; } -#filter_box_background { top: 0px; left: 196px; } -#filter_box_border { top: 0px; left: 217px; } - - -/* BIG OPTIONS BUTTONS */ -#options_tabs_indentation_indicator { z-index: 3000; display: float; position: absolute; top: 25px; left: 550px; height: 30px; width: 80px; background-size: 80px 30px; background-image: url(../options/options_tabs_indentation_indicator.svg);} -#options_tabs_roundness_indicator { z-index: 3000; display: float; position: absolute; top: 25px; left: 640px; height: 30px; width: 80px; background-size: 80px 30px; background-image: url(../options/options_tabs_roundness_indicator.svg);} -#options_tabs_size_indicator { z-index: 3000; display: float; position: absolute; top: 25px; left: 730px; height: 30px; width: 80px; background-size: 80px 30px; background-image: url(../options/options_tabs_size_indicator.svg);} - -/* SCROLLBAR RESIZE */ -#scrollbar_size_indicator {z-index: 3000; display: float; position: absolute; top: 20px; left: 335px; height: 80px; width: 80px; background-size: 80px 80px; background-image: url(../options/options_scrollbar_size_indicator.svg); } -#options_tab_list_scrollbar_width_down { left: 3px; top: 30px; } -#options_tab_list_scrollbar_width_up { left: 57px; top: 30px; } -#options_tab_list_scrollbar_height_up { left: 30px; top: 3px; } -#options_tab_list_scrollbar_height_down { left: 30px; top: 57px; } - - -/* PIN LIST AND SCROLLBAR */ -#pin_list { position: absolute; height: calc(var(--scrollbar_height) + var(--pin_height)); width: 788px; top: 30px; left: 20px;} - -#pin_list_scrollbar { position: absolute; height: var(--scrollbar_height); width: 790px; top: calc(var(--pin_height) + 31px); left: 20px; z-index: 1000; background-color: var(--scrollbar_track); } -#pin_list_scrollbar_thumb { position: relative; height: 100%; width: 100px; top: 0px; left: 0px; z-index: 1200; background-color: var(--scrollbar_thumb); } -#pin_list_scrollbar_thumb:hover { background-color: var(--scrollbar_thumb_hover); } - - - -/* PINS */ -#pin_list_options_block {z-index: 2000; position:absolute; width: 500px; height: var(--pin_height); top: 30px; left: 20px; margin: 0; /* background:rgba(0,0,255,0.1); */ } -#pin_list_background { top: 1px; left: 187px; } -#pin_list_border_bottom { top: 1px; left: 164px; } - - -/* ATTENTION PIN */ -#attention_background { top: 1px; left: 72px; } -#attention_border { top: 1px; left: 93px; } - - - -/* TAB LIST AND SCROLLBAR */ -#tab_list { position: absolute; height: 800px; width: calc(770px - var(--scrollbar_width)); top: calc(var(--scrollbar_height) + var(--pin_height) + 32px); left: 40px; z-index: 1000 } - -#group_scrollbar { position: absolute; height: 800px; width: var(--scrollbar_width); top: calc(var(--scrollbar_height) + var(--pin_height) + 32px); left: calc(810px - var(--scrollbar_width)); z-index: 1000; background-color: var(--scrollbar_track); } -#group_scrollbar_thumb { position: relative; height: 200px; width: 100%; top: 140px; left: 0px; z-index: 1000; background-color: var(--scrollbar_thumb); } -#group_scrollbar_thumb:hover { background-color: var(--scrollbar_thumb_hover); } -#scrollbar_thumb { position: absolute; top: 370px; left: 790px; } -#scrollbar_thumb_hover { position: absolute; top: 390px; left: 790px; } -#scrollbar_track { position: absolute; top: 410px; left: 790px; } - -#Tabs { - --row_image_size: 18px 18px; -} -/* TABS */ -#tabs_options_block {z-index: 2000; position:absolute; width: 740px; height: auto; top: calc(var(--scrollbar_height) + var(--pin_height) + 32px); left: 50px; margin: 0; /* background:rgba(0,255,0,0.5); */ } - -.tab_color_options_row {z-index: 2000; position:relative; width: 740px; height: 20px; /* background:rgba(255,0,0,0.1); */ } -.tab_color_options_row>.color_border {top: 1px; left: 659px; background-size: var(--row_image_size);} -.tab_color_options_row>.color_bucket {top: 1px; left: 680px; background-size: var(--row_image_size);} -.tab_color_options_row>.font_color {top: 1px; left: 509px; background-size: var(--row_image_size);} -.tab_color_options_row>.font_weight_normal {top: 1px; left: 538px; background-size: var(--row_image_size);} -.tab_color_options_row>.font_weight_bold {top: 1px; left: 559px; background-size: var(--row_image_size);} -.tab_color_options_row>.font_style_normal {top: 1px; left: 588px; background-size: var(--row_image_size);} -.tab_color_options_row>.font_style_italic {top: 1px; left: 609px; background-size: var(--row_image_size);} - - -/* DRAG AND DROP INDICATOR */ -#dd19 { display: inline-block; border-bottom: 2px solid var(--drag_indicator); } -#drag_indicator { top: 8px; left: 350px; background-size: var(--row_image_size);} - - -/* CLOSE TAB BUTTON OPTIONS */ -#close_x { top: 0px; left: calc(753px - var(--scrollbar_width)); background-size: var(--row_image_size);} -#close_hover_x { top: -16px; left: calc(753px - var(--scrollbar_width)); background-size: var(--row_image_size);} -#close_hover_border { top: 2px; left: calc(753px - var(--scrollbar_width)); background-size: var(--row_image_size);} -#close_hover_background { top: 20px; left: calc(753px - var(--scrollbar_width)); background-size: var(--row_image_size);} - - -/* CLOSE TAB BUTTON OPTIONS */ -#expand_hover_background { top: 1px; left: calc(var(--children_padding_left) - 18px); background-size: var(--row_image_size);} -#expand_closed_background { top: 1px; left: calc(var(--children_padding_left) - 18px); background-size: var(--row_image_size);} -#expand_open_background { top: 1px; left: -12px; background-size: var(--row_image_size);} - - -#tab_list_background { top: 835px; left: 50px; } - - - -#toolbar_groups_block { position: absolute; left: 20px; top: calc(var(--scrollbar_height) + var(--pin_height) + 32px); width: 19px; height: 800px; background-color: var(--group_list_background); border-right: 1px solid var(--group_list_borders); overflow: visible; } -#_gtetab_list { width: 200px; height: 20px; } -#_gtetab_list2 { width: 200px; height: 20px; } -#_tab_list2:hover { background-color: var(--group_list_button_hover_background); } - -#group_list_background { top: 835px; left: 20px; } -#group_list_borders { top: 631px; left: 20px; } -#group_list_default_font_color { top: 652px; left: 20px; } -#group_list_button_hover_background { top: 610px; left: 20px; } - - -/* MENU */ -#tabs_menu_border { top: 59px; left: 80px; } -#tabs_menu_background { top: 59px; left: 102px; } -#tabs_menu_font { top: 36px; left: 102px; } -#tabs_menu_hover_border { top: 14px; left: 80px; } -#tabs_menu_hover_background { top: 14px; left: 102px; } -#tabs_menu_separator { top: 36px; left: 80px; } - diff --git a/options/theme_size_settings_2.css b/options/theme_size_settings_2.css deleted file mode 100644 index bd8011c..0000000 --- a/options/theme_size_settings_2.css +++ /dev/null @@ -1,168 +0,0 @@ -/* OPTIONS IMAGES */ -.font_color {z-index: 1000; position: absolute; display: float; height: 20px; width: 20px; background-size: 20px 20px; background-image: url(../options/options_font_color.svg);} -.font_color:hover {background-image: url(../options/options_font_color_hover.svg);} -.font_weight_normal {z-index: 1000; position: absolute; display: float; height: 20px; width: 20px; background-size: 20px 20px; background-image: url(../options/options_font_style_normal.svg);} -.font_weight_normal:hover {background-image: url(../options/options_font_style_normal_hover.svg);} -.font_weight_bold {z-index: 1000; position: absolute; display: float; height: 20px; width: 20px; background-size: 20px 20px; background-image: url(../options/options_font_weight_bold.svg);} -.font_weight_bold:hover {background-image: url(../options/options_font_weight_bold_hover.svg);} -.font_style_normal {z-index: 1000; position: absolute; display: float; height: 20px; width: 20px; background-size: 20px 20px; background-image: url(../options/options_font_style_normal.svg);} -.font_style_normal:hover {background-image: url(../options/options_font_style_normal_hover.svg);} -.font_style_italic {z-index: 1000; position: absolute; display: float; height: 20px; width: 20px; background-size: 20px 20px; background-image: url(../options/options_font_style_italic.svg);} -.font_style_italic:hover {background-image: url(../options/options_font_style_italic_hover.svg);} - -.color_toolbar_icon {z-index: 10000; position: absolute; display: block; height: 20px; width: 20px; background-size: 20px 20px; background-image: url(../options/options_color_toolbar_icon.svg);} -.color_toolbar_icon:hover {background-image: url(../options/options_color_toolbar_icon_hover.svg);} - -.color_bucket {z-index: 10000; position: absolute; display: float; height: 20px; width: 20px; background-size: 20px 20px; background-image: url(../options/options_color_bucket.svg);} -.color_bucket:hover {background-image: url(../options/options_color_bucket_hover.svg);} - -.color_brush {z-index: 10000; position: absolute; display: float; height: 20px; width: 20px; background-size: 20px 20px; background-image: url(../options/options_color_brush.svg);} -.color_brush:hover {background-image: url(../options/options_color_brush_hover.svg);} - -.color_border {z-index: 10000; position: absolute; display: float; height: 20px; width: 20px; background-size: 20px 20px; background-image: url(../options/options_color_border.svg);} -.color_border:hover {background-image: url(../options/options_color_border_hover.svg);} - -.color_x {z-index: 10000; position: absolute; display: float; height: 20px; width: 20px; background-size: 20px 20px; background-image: url(../options/options_color_x.svg);} -.color_x:hover {background-image: url(../options/options_color_x_hover.svg);} - -.options_button_minus {z-index: 10000; display: float; position: absolute; top: 5px; left: 6px; height: 20px; width: 20px; background-size: 20px 20px; background-image: url(../options/options_scale_minus.svg);} -.options_button_minus:hover {background-image: url(../options/options_scale_minus_hover.svg);} -.options_button_plus {z-index: 10000; display: float; position: absolute; top: 5px; left: 54px; height: 20px; width: 20px; background-size: 20px 20px; background-image: url(../options/options_scale_plus.svg);} -.options_button_plus:hover {background-image: url(../options/options_scale_plus_hover.svg);} - -@keyframes hover_blinking { - 0% {background-color: transparent;} - 100% {background-color: blue;} -} -.hover_blinking { - animation: hover_blinking 1s infinite; -} - -@keyframes hover_border_blinking { - 0% {border: 1px solid transparent;} - 100% {border: 1px solid blue;} -} -.hover_border_blinking { - animation: hover_border_blinking 1s infinite; -} - -/* MAIN TOOLBAR */ -#toolbar_background { top: 0px; left: 307px; } -#toolbar_border_bottom { top: 0px; left: 328px; } - -#button_icons { top: 0px; left: 59px; } -#button_icons_hover { top: 0px; left: 80px; } - -#button_background { top: 0px; left: 4px; } -#button_hover_background { top: 0px; left: 25px; } - -#button_border { top: 0px; left: 115px; } -#button_hover_border { top: 0px; left: 136px; } - -#filter_box_font { top: 0px; left: 175px; } -#filter_clear_icon { top: 0px; left: 238px; } -#filter_box_background { top: 0px; left: 196px; } -#filter_box_border { top: 0px; left: 217px; } - - -/* BIG OPTIONS BUTTONS */ -#options_tabs_indentation_indicator { z-index: 3000; display: float; position: absolute; top: 25px; left: 550px; height: 30px; width: 80px; background-size: 80px 30px; background-image: url(../options/options_tabs_indentation_indicator.svg);} -#options_tabs_roundness_indicator { z-index: 3000; display: float; position: absolute; top: 25px; left: 640px; height: 30px; width: 80px; background-size: 80px 30px; background-image: url(../options/options_tabs_roundness_indicator.svg);} -#options_tabs_size_indicator { z-index: 3000; display: float; position: absolute; top: 25px; left: 730px; height: 30px; width: 80px; background-size: 80px 30px; background-image: url(../options/options_tabs_size_indicator.svg);} - -/* SCROLLBAR RESIZE */ -#scrollbar_size_indicator {z-index: 3000; display: float; position: absolute; top: 20px; left: 335px; height: 80px; width: 80px; background-size: 80px 80px; background-image: url(../options/options_scrollbar_size_indicator.svg); } -#options_tab_list_scrollbar_width_down { left: 3px; top: 30px; } -#options_tab_list_scrollbar_width_up { left: 57px; top: 30px; } -#options_tab_list_scrollbar_height_up { left: 30px; top: 3px; } -#options_tab_list_scrollbar_height_down { left: 30px; top: 57px; } - - -/* PIN LIST AND SCROLLBAR */ -#pin_list { position: absolute; height: calc(var(--scrollbar_height) + var(--pin_height)); width: 788px; top: 30px; left: 20px;} - -#pin_list_scrollbar { position: absolute; height: var(--scrollbar_height); width: 790px; top: calc(var(--pin_height) + 31px); left: 20px; z-index: 1000; background-color: var(--scrollbar_track); } -#pin_list_scrollbar_thumb { position: relative; height: 100%; width: 100px; top: 0px; left: 0px; z-index: 1200; background-color: var(--scrollbar_thumb); } -#pin_list_scrollbar_thumb:hover { background-color: var(--scrollbar_thumb_hover); } - - - -/* PINS */ -#pin_list_options_block {z-index: 2000; position:absolute; width: 500px; height: var(--pin_height); top: 30px; left: 20px; margin: 0; /* background:rgba(0,0,255,0.1); */ } -#pin_list_background { top: 3px; left: 187px; } -#pin_list_border_bottom { top: 3px; left: 164px; } - - -/* ATTENTION PIN */ -#attention_background { top: 3px; left: 72px; } -#attention_border { top: 3px; left: 93px; } - - - -/* TAB LIST AND SCROLLBAR */ -#tab_list { position: absolute; height: 800px; width: calc(770px - var(--scrollbar_width)); top: calc(var(--scrollbar_height) + var(--pin_height) + 32px); left: 40px; z-index: 1000 } - -#group_scrollbar { position: absolute; height: 800px; width: var(--scrollbar_width); top: calc(var(--scrollbar_height) + var(--pin_height) + 32px); left: calc(810px - var(--scrollbar_width)); z-index: 1000; background-color: var(--scrollbar_track); } -#group_scrollbar_thumb { position: relative; height: 200px; width: 100%; top: 140px; left: 0px; z-index: 1000; background-color: var(--scrollbar_thumb); } -#group_scrollbar_thumb:hover { background-color: var(--scrollbar_thumb_hover); } -#scrollbar_thumb { position: absolute; top: 370px; left: 790px; } -#scrollbar_thumb_hover { position: absolute; top: 390px; left: 790px; } -#scrollbar_track { position: absolute; top: 410px; left: 790px; } - -#Tabs { - --row_image_size: 20px 20px; -} -/* TABS */ -#tabs_options_block {z-index: 2000; position:absolute; width: 740px; height: auto; top: calc(var(--scrollbar_height) + var(--pin_height) + 32px); left: 50px; margin: 0; /* background:rgba(0,255,0,0.5); */ } - -.tab_color_options_row {z-index: 2000; position:relative; width: 740px; height: 22px; /* background:rgba(255,0,0,0.1); */ } -.tab_color_options_row>.color_border {top: 1px; left: 659px; background-size: var(--row_image_size);} -.tab_color_options_row>.color_bucket {top: 1px; left: 680px; background-size: var(--row_image_size);} -.tab_color_options_row>.font_color {top: 1px; left: 509px; background-size: var(--row_image_size);} -.tab_color_options_row>.font_weight_normal {top: 1px; left: 538px; background-size: var(--row_image_size);} -.tab_color_options_row>.font_weight_bold {top: 1px; left: 559px; background-size: var(--row_image_size);} -.tab_color_options_row>.font_style_normal {top: 1px; left: 588px; background-size: var(--row_image_size);} -.tab_color_options_row>.font_style_italic {top: 1px; left: 609px; background-size: var(--row_image_size);} - - -/* DRAG AND DROP INDICATOR */ -#dd19 { display: inline-block; border-bottom: 2px solid var(--drag_indicator); } -#drag_indicator { top: 8px; left: 350px; background-size: var(--row_image_size);} - - -/* CLOSE TAB BUTTON OPTIONS */ -#close_x { top: 0px; left: calc(753px - var(--scrollbar_width)); background-size: var(--row_image_size);} -#close_hover_x { top: -18px; left: calc(753px - var(--scrollbar_width)); background-size: var(--row_image_size);} -#close_hover_border { top: 2px; left: calc(753px - var(--scrollbar_width)); background-size: var(--row_image_size);} -#close_hover_background { top: 22px; left: calc(753px - var(--scrollbar_width)); background-size: var(--row_image_size);} - - -/* CLOSE TAB BUTTON OPTIONS */ -#expand_hover_background { top: 1px; left: calc(var(--children_padding_left) - 18px); background-size: var(--row_image_size);} -#expand_closed_background { top: 1px; left: calc(var(--children_padding_left) - 18px); background-size: var(--row_image_size);} -#expand_open_background { top: 1px; left: -12px; background-size: var(--row_image_size);} - - -#tab_list_background { top: 835px; left: 50px; } - - - -#toolbar_groups_block { position: absolute; left: 20px; top: calc(var(--scrollbar_height) + var(--pin_height) + 32px); width: 19px; height: 800px; background-color: var(--group_list_background); border-right: 1px solid var(--group_list_borders); overflow: visible; } -#_gtetab_list { width: 200px; height: 20px; } -#_gtetab_list2 { width: 200px; height: 20px; } -#_tab_list2:hover { background-color: var(--group_list_button_hover_background); } - -#group_list_background { top: 835px; left: 20px; } -#group_list_borders { top: 631px; left: 20px; } -#group_list_default_font_color { top: 652px; left: 20px; } -#group_list_button_hover_background { top: 610px; left: 20px; } - - -/* MENU */ -#tabs_menu_border { top: 59px; left: 80px; } -#tabs_menu_background { top: 59px; left: 102px; } -#tabs_menu_font { top: 36px; left: 102px; } -#tabs_menu_hover_border { top: 14px; left: 80px; } -#tabs_menu_hover_background { top: 14px; left: 102px; } -#tabs_menu_separator { top: 36px; left: 80px; } - diff --git a/options/theme_size_settings_3.css b/options/theme_size_settings_3.css deleted file mode 100644 index 8c77241..0000000 --- a/options/theme_size_settings_3.css +++ /dev/null @@ -1,168 +0,0 @@ -/* OPTIONS IMAGES */ -.font_color {z-index: 1000; position: absolute; display: float; height: 20px; width: 20px; background-size: 20px 20px; background-image: url(../options/options_font_color.svg);} -.font_color:hover {background-image: url(../options/options_font_color_hover.svg);} -.font_weight_normal {z-index: 1000; position: absolute; display: float; height: 20px; width: 20px; background-size: 20px 20px; background-image: url(../options/options_font_style_normal.svg);} -.font_weight_normal:hover {background-image: url(../options/options_font_style_normal_hover.svg);} -.font_weight_bold {z-index: 1000; position: absolute; display: float; height: 20px; width: 20px; background-size: 20px 20px; background-image: url(../options/options_font_weight_bold.svg);} -.font_weight_bold:hover {background-image: url(../options/options_font_weight_bold_hover.svg);} -.font_style_normal {z-index: 1000; position: absolute; display: float; height: 20px; width: 20px; background-size: 20px 20px; background-image: url(../options/options_font_style_normal.svg);} -.font_style_normal:hover {background-image: url(../options/options_font_style_normal_hover.svg);} -.font_style_italic {z-index: 1000; position: absolute; display: float; height: 20px; width: 20px; background-size: 20px 20px; background-image: url(../options/options_font_style_italic.svg);} -.font_style_italic:hover {background-image: url(../options/options_font_style_italic_hover.svg);} - -.color_toolbar_icon {z-index: 10000; position: absolute; display: block; height: 20px; width: 20px; background-size: 20px 20px; background-image: url(../options/options_color_toolbar_icon.svg);} -.color_toolbar_icon:hover {background-image: url(../options/options_color_toolbar_icon_hover.svg);} - -.color_bucket {z-index: 10000; position: absolute; display: float; height: 20px; width: 20px; background-size: 20px 20px; background-image: url(../options/options_color_bucket.svg);} -.color_bucket:hover {background-image: url(../options/options_color_bucket_hover.svg);} - -.color_brush {z-index: 10000; position: absolute; display: float; height: 20px; width: 20px; background-size: 20px 20px; background-image: url(../options/options_color_brush.svg);} -.color_brush:hover {background-image: url(../options/options_color_brush_hover.svg);} - -.color_border {z-index: 10000; position: absolute; display: float; height: 20px; width: 20px; background-size: 20px 20px; background-image: url(../options/options_color_border.svg);} -.color_border:hover {background-image: url(../options/options_color_border_hover.svg);} - -.color_x {z-index: 10000; position: absolute; display: float; height: 20px; width: 20px; background-size: 20px 20px; background-image: url(../options/options_color_x.svg);} -.color_x:hover {background-image: url(../options/options_color_x_hover.svg);} - -.options_button_minus {z-index: 10000; display: float; position: absolute; top: 5px; left: 6px; height: 20px; width: 20px; background-size: 20px 20px; background-image: url(../options/options_scale_minus.svg);} -.options_button_minus:hover {background-image: url(../options/options_scale_minus_hover.svg);} -.options_button_plus {z-index: 10000; display: float; position: absolute; top: 5px; left: 54px; height: 20px; width: 20px; background-size: 20px 20px; background-image: url(../options/options_scale_plus.svg);} -.options_button_plus:hover {background-image: url(../options/options_scale_plus_hover.svg);} - -@keyframes hover_blinking { - 0% {background-color: transparent;} - 100% {background-color: blue;} -} -.hover_blinking { - animation: hover_blinking 1s infinite; -} - -@keyframes hover_border_blinking { - 0% {border: 1px solid transparent;} - 100% {border: 1px solid blue;} -} -.hover_border_blinking { - animation: hover_border_blinking 1s infinite; -} - -/* MAIN TOOLBAR */ -#toolbar_background { top: 0px; left: 307px; } -#toolbar_border_bottom { top: 0px; left: 328px; } - -#button_icons { top: 0px; left: 59px; } -#button_icons_hover { top: 0px; left: 80px; } - -#button_background { top: 0px; left: 4px; } -#button_hover_background { top: 0px; left: 25px; } - -#button_border { top: 0px; left: 115px; } -#button_hover_border { top: 0px; left: 136px; } - -#filter_box_font { top: 0px; left: 175px; } -#filter_clear_icon { top: 0px; left: 238px; } -#filter_box_background { top: 0px; left: 196px; } -#filter_box_border { top: 0px; left: 217px; } - - -/* BIG OPTIONS BUTTONS */ -#options_tabs_indentation_indicator { z-index: 3000; display: float; position: absolute; top: 25px; left: 550px; height: 30px; width: 80px; background-size: 80px 30px; background-image: url(../options/options_tabs_indentation_indicator.svg);} -#options_tabs_roundness_indicator { z-index: 3000; display: float; position: absolute; top: 25px; left: 640px; height: 30px; width: 80px; background-size: 80px 30px; background-image: url(../options/options_tabs_roundness_indicator.svg);} -#options_tabs_size_indicator { z-index: 3000; display: float; position: absolute; top: 25px; left: 730px; height: 30px; width: 80px; background-size: 80px 30px; background-image: url(../options/options_tabs_size_indicator.svg);} - -/* SCROLLBAR RESIZE */ -#scrollbar_size_indicator {z-index: 3000; display: float; position: absolute; top: 20px; left: 335px; height: 80px; width: 80px; background-size: 80px 80px; background-image: url(../options/options_scrollbar_size_indicator.svg); } -#options_tab_list_scrollbar_width_down { left: 3px; top: 30px; } -#options_tab_list_scrollbar_width_up { left: 57px; top: 30px; } -#options_tab_list_scrollbar_height_up { left: 30px; top: 3px; } -#options_tab_list_scrollbar_height_down { left: 30px; top: 57px; } - - -/* PIN LIST AND SCROLLBAR */ -#pin_list { position: absolute; height: calc(var(--scrollbar_height) + var(--pin_height)); width: 788px; top: 30px; left: 20px;} - -#pin_list_scrollbar { position: absolute; height: var(--scrollbar_height); width: 790px; top: calc(var(--pin_height) + 31px); left: 20px; z-index: 1000; background-color: var(--scrollbar_track); } -#pin_list_scrollbar_thumb { position: relative; height: 100%; width: 100px; top: 0px; left: 0px; z-index: 1200; background-color: var(--scrollbar_thumb); } -#pin_list_scrollbar_thumb:hover { background-color: var(--scrollbar_thumb_hover); } - - - -/* PINS */ -#pin_list_options_block {z-index: 2000; position:absolute; width: 500px; height: var(--pin_height); top: 30px; left: 20px; margin: 0; /* background:rgba(0,0,255,0.1); */ } -#pin_list_background { top: 3px; left: 187px; } -#pin_list_border_bottom { top: 3px; left: 164px; } - - -/* ATTENTION PIN */ -#attention_background { top: 3px; left: 72px; } -#attention_border { top: 3px; left: 93px; } - - - -/* TAB LIST AND SCROLLBAR */ -#tab_list { position: absolute; height: 800px; width: calc(770px - var(--scrollbar_width)); top: calc(var(--scrollbar_height) + var(--pin_height) + 32px); left: 40px; z-index: 1000 } - -#group_scrollbar { position: absolute; height: 800px; width: var(--scrollbar_width); top: calc(var(--scrollbar_height) + var(--pin_height) + 32px); left: calc(810px - var(--scrollbar_width)); z-index: 1000; background-color: var(--scrollbar_track); } -#group_scrollbar_thumb { position: relative; height: 200px; width: 100%; top: 140px; left: 0px; z-index: 1000; background-color: var(--scrollbar_thumb); } -#group_scrollbar_thumb:hover { background-color: var(--scrollbar_thumb_hover); } -#scrollbar_thumb { position: absolute; top: 370px; left: 790px; } -#scrollbar_thumb_hover { position: absolute; top: 390px; left: 790px; } -#scrollbar_track { position: absolute; top: 410px; left: 790px; } - -#Tabs { - --row_image_size: 20px 20px; -} -/* TABS */ -#tabs_options_block {z-index: 2000; position:absolute; width: 740px; height: auto; top: calc(var(--scrollbar_height) + var(--pin_height) + 32px); left: 50px; margin: 0; /* background:rgba(0,255,0,0.5); */ } - -.tab_color_options_row {z-index: 2000; position:relative; width: 740px; height: 24px; /* background:rgba(255,0,0,0.1); */ } -.tab_color_options_row>.color_border {top: 2px; left: 659px; background-size: var(--row_image_size);} -.tab_color_options_row>.color_bucket {top: 2px; left: 680px; background-size: var(--row_image_size);} -.tab_color_options_row>.font_color {top: 2px; left: 509px; background-size: var(--row_image_size);} -.tab_color_options_row>.font_weight_normal {top: 2px; left: 538px; background-size: var(--row_image_size);} -.tab_color_options_row>.font_weight_bold {top: 2px; left: 559px; background-size: var(--row_image_size);} -.tab_color_options_row>.font_style_normal {top: 2px; left: 588px; background-size: var(--row_image_size);} -.tab_color_options_row>.font_style_italic {top: 2px; left: 609px; background-size: var(--row_image_size);} - - -/* DRAG AND DROP INDICATOR */ -#dd19 { display: inline-block; border-bottom: 2px solid var(--drag_indicator); } -#drag_indicator { top: 8px; left: 350px; background-size: var(--row_image_size);} - - -/* CLOSE TAB BUTTON OPTIONS */ -#close_x { top: 0px; left: calc(753px - var(--scrollbar_width)); background-size: var(--row_image_size);} -#close_hover_x { top: -18px; left: calc(753px - var(--scrollbar_width)); background-size: var(--row_image_size);} -#close_hover_border { top: 2px; left: calc(753px - var(--scrollbar_width)); background-size: var(--row_image_size);} -#close_hover_background { top: 22px; left: calc(753px - var(--scrollbar_width)); background-size: var(--row_image_size);} - - -/* CLOSE TAB BUTTON OPTIONS */ -#expand_hover_background { top: 2px; left: calc(var(--children_padding_left) - 18px); background-size: var(--row_image_size);} -#expand_closed_background { top: 2px; left: calc(var(--children_padding_left) - 18px); background-size: var(--row_image_size);} -#expand_open_background { top: 2px; left: -12px; background-size: var(--row_image_size);} - - -#tab_list_background { top: 835px; left: 50px; } - - - -#toolbar_groups_block { position: absolute; left: 20px; top: calc(var(--scrollbar_height) + var(--pin_height) + 32px); width: 19px; height: 800px; background-color: var(--group_list_background); border-right: 1px solid var(--group_list_borders); overflow: visible; } -#_gtetab_list { width: 200px; height: 20px; } -#_gtetab_list2 { width: 200px; height: 20px; } -#_tab_list2:hover { background-color: var(--group_list_button_hover_background); } - -#group_list_background { top: 835px; left: 20px; } -#group_list_borders { top: 631px; left: 20px; } -#group_list_default_font_color { top: 652px; left: 20px; } -#group_list_button_hover_background { top: 610px; left: 20px; } - - -/* MENU */ -#tabs_menu_border { top: 59px; left: 80px; } -#tabs_menu_background { top: 59px; left: 102px; } -#tabs_menu_font { top: 36px; left: 102px; } -#tabs_menu_hover_border { top: 14px; left: 80px; } -#tabs_menu_hover_background { top: 14px; left: 102px; } -#tabs_menu_separator { top: 36px; left: 80px; } - diff --git a/options/theme_size_settings_4.css b/options/theme_size_settings_4.css deleted file mode 100644 index 1c8910a..0000000 --- a/options/theme_size_settings_4.css +++ /dev/null @@ -1,168 +0,0 @@ -/* OPTIONS IMAGES */ -.font_color {z-index: 1000; position: absolute; display: float; height: 20px; width: 20px; background-size: 20px 20px; background-image: url(../options/options_font_color.svg);} -.font_color:hover {background-image: url(../options/options_font_color_hover.svg);} -.font_weight_normal {z-index: 1000; position: absolute; display: float; height: 20px; width: 20px; background-size: 20px 20px; background-image: url(../options/options_font_style_normal.svg);} -.font_weight_normal:hover {background-image: url(../options/options_font_style_normal_hover.svg);} -.font_weight_bold {z-index: 1000; position: absolute; display: float; height: 20px; width: 20px; background-size: 20px 20px; background-image: url(../options/options_font_weight_bold.svg);} -.font_weight_bold:hover {background-image: url(../options/options_font_weight_bold_hover.svg);} -.font_style_normal {z-index: 1000; position: absolute; display: float; height: 20px; width: 20px; background-size: 20px 20px; background-image: url(../options/options_font_style_normal.svg);} -.font_style_normal:hover {background-image: url(../options/options_font_style_normal_hover.svg);} -.font_style_italic {z-index: 1000; position: absolute; display: float; height: 20px; width: 20px; background-size: 20px 20px; background-image: url(../options/options_font_style_italic.svg);} -.font_style_italic:hover {background-image: url(../options/options_font_style_italic_hover.svg);} - -.color_toolbar_icon {z-index: 10000; position: absolute; display: block; height: 20px; width: 20px; background-size: 20px 20px; background-image: url(../options/options_color_toolbar_icon.svg);} -.color_toolbar_icon:hover {background-image: url(../options/options_color_toolbar_icon_hover.svg);} - -.color_bucket {z-index: 10000; position: absolute; display: float; height: 20px; width: 20px; background-size: 20px 20px; background-image: url(../options/options_color_bucket.svg);} -.color_bucket:hover {background-image: url(../options/options_color_bucket_hover.svg);} - -.color_brush {z-index: 10000; position: absolute; display: float; height: 20px; width: 20px; background-size: 20px 20px; background-image: url(../options/options_color_brush.svg);} -.color_brush:hover {background-image: url(../options/options_color_brush_hover.svg);} - -.color_border {z-index: 10000; position: absolute; display: float; height: 20px; width: 20px; background-size: 20px 20px; background-image: url(../options/options_color_border.svg);} -.color_border:hover {background-image: url(../options/options_color_border_hover.svg);} - -.color_x {z-index: 10000; position: absolute; display: float; height: 20px; width: 20px; background-size: 20px 20px; background-image: url(../options/options_color_x.svg);} -.color_x:hover {background-image: url(../options/options_color_x_hover.svg);} - -.options_button_minus {z-index: 10000; display: float; position: absolute; top: 5px; left: 6px; height: 20px; width: 20px; background-size: 20px 20px; background-image: url(../options/options_scale_minus.svg);} -.options_button_minus:hover {background-image: url(../options/options_scale_minus_hover.svg);} -.options_button_plus {z-index: 10000; display: float; position: absolute; top: 5px; left: 54px; height: 20px; width: 20px; background-size: 20px 20px; background-image: url(../options/options_scale_plus.svg);} -.options_button_plus:hover {background-image: url(../options/options_scale_plus_hover.svg);} - -@keyframes hover_blinking { - 0% {background-color: transparent;} - 100% {background-color: blue;} -} -.hover_blinking { - animation: hover_blinking 1s infinite; -} - -@keyframes hover_border_blinking { - 0% {border: 1px solid transparent;} - 100% {border: 1px solid blue;} -} -.hover_border_blinking { - animation: hover_border_blinking 1s infinite; -} - -/* MAIN TOOLBAR */ -#toolbar_background { top: 0px; left: 307px; } -#toolbar_border_bottom { top: 0px; left: 328px; } - -#button_icons { top: 0px; left: 59px; } -#button_icons_hover { top: 0px; left: 80px; } - -#button_background { top: 0px; left: 4px; } -#button_hover_background { top: 0px; left: 25px; } - -#button_border { top: 0px; left: 115px; } -#button_hover_border { top: 0px; left: 136px; } - -#filter_box_font { top: 0px; left: 175px; } -#filter_clear_icon { top: 0px; left: 238px; } -#filter_box_background { top: 0px; left: 196px; } -#filter_box_border { top: 0px; left: 217px; } - - -/* BIG OPTIONS BUTTONS */ -#options_tabs_indentation_indicator { z-index: 3000; display: float; position: absolute; top: 25px; left: 550px; height: 30px; width: 80px; background-size: 80px 30px; background-image: url(../options/options_tabs_indentation_indicator.svg);} -#options_tabs_roundness_indicator { z-index: 3000; display: float; position: absolute; top: 25px; left: 640px; height: 30px; width: 80px; background-size: 80px 30px; background-image: url(../options/options_tabs_roundness_indicator.svg);} -#options_tabs_size_indicator { z-index: 3000; display: float; position: absolute; top: 25px; left: 730px; height: 30px; width: 80px; background-size: 80px 30px; background-image: url(../options/options_tabs_size_indicator.svg);} - -/* SCROLLBAR RESIZE */ -#scrollbar_size_indicator {z-index: 3000; display: float; position: absolute; top: 20px; left: 335px; height: 80px; width: 80px; background-size: 80px 80px; background-image: url(../options/options_scrollbar_size_indicator.svg); } -#options_tab_list_scrollbar_width_down { left: 3px; top: 30px; } -#options_tab_list_scrollbar_width_up { left: 57px; top: 30px; } -#options_tab_list_scrollbar_height_up { left: 30px; top: 3px; } -#options_tab_list_scrollbar_height_down { left: 30px; top: 57px; } - - -/* PIN LIST AND SCROLLBAR */ -#pin_list { position: absolute; height: calc(var(--scrollbar_height) + var(--pin_height)); width: 788px; top: 30px; left: 20px;} - -#pin_list_scrollbar { position: absolute; height: var(--scrollbar_height); width: 790px; top: calc(var(--pin_height) + 31px); left: 20px; z-index: 1000; background-color: var(--scrollbar_track); } -#pin_list_scrollbar_thumb { position: relative; height: 100%; width: 100px; top: 0px; left: 0px; z-index: 1200; background-color: var(--scrollbar_thumb); } -#pin_list_scrollbar_thumb:hover { background-color: var(--scrollbar_thumb_hover); } - - - -/* PINS */ -#pin_list_options_block {z-index: 2000; position:absolute; width: 500px; height: var(--pin_height); top: 30px; left: 20px; margin: 0; /* background:rgba(0,0,255,0.1); */ } -#pin_list_background { top: 4px; left: 187px; } -#pin_list_border_bottom { top: 4px; left: 164px; } - - -/* ATTENTION PIN */ -#attention_background { top: 4px; left: 72px; } -#attention_border { top: 4px; left: 93px; } - - - -/* TAB LIST AND SCROLLBAR */ -#tab_list { position: absolute; height: 800px; width: calc(770px - var(--scrollbar_width)); top: calc(var(--scrollbar_height) + var(--pin_height) + 32px); left: 40px; z-index: 1000 } - -#group_scrollbar { position: absolute; height: 800px; width: var(--scrollbar_width); top: calc(var(--scrollbar_height) + var(--pin_height) + 32px); left: calc(810px - var(--scrollbar_width)); z-index: 1000; background-color: var(--scrollbar_track); } -#group_scrollbar_thumb { position: relative; height: 200px; width: 100%; top: 140px; left: 0px; z-index: 1000; background-color: var(--scrollbar_thumb); } -#group_scrollbar_thumb:hover { background-color: var(--scrollbar_thumb_hover); } -#scrollbar_thumb { position: absolute; top: 370px; left: 790px; } -#scrollbar_thumb_hover { position: absolute; top: 390px; left: 790px; } -#scrollbar_track { position: absolute; top: 410px; left: 790px; } - -#Tabs { - --row_image_size: 20px 20px; -} -/* TABS */ -#tabs_options_block {z-index: 2000; position:absolute; width: 740px; height: auto; top: calc(var(--scrollbar_height) + var(--pin_height) + 36px); left: 50px; margin: 0; /* background:rgba(0,255,0,0.5); */ } - -.tab_color_options_row {z-index: 2000; position:relative; width: 740px; height: 26px; /* background:rgba(255,0,0,0.1); */ } -.tab_color_options_row>.color_border {top: 0px; left: 659px; background-size: var(--row_image_size);} -.tab_color_options_row>.color_bucket {top: 0px; left: 680px; background-size: var(--row_image_size);} -.tab_color_options_row>.font_color {top: 0px; left: 509px; background-size: var(--row_image_size);} -.tab_color_options_row>.font_weight_normal {top: 0px; left: 538px; background-size: var(--row_image_size);} -.tab_color_options_row>.font_weight_bold {top: 0px; left: 559px; background-size: var(--row_image_size);} -.tab_color_options_row>.font_style_normal {top: 0px; left: 588px; background-size: var(--row_image_size);} -.tab_color_options_row>.font_style_italic {top: 0px; left: 609px; background-size: var(--row_image_size);} - - -/* DRAG AND DROP INDICATOR */ -#dd19 { display: inline-block; border-bottom: 2px solid var(--drag_indicator); } -#drag_indicator { top: 8px; left: 350px; background-size: var(--row_image_size);} - - -/* CLOSE TAB BUTTON OPTIONS */ -#close_x { top: 0px; left: calc(753px - var(--scrollbar_width)); background-size: var(--row_image_size);} -#close_hover_x { top: -20px; left: calc(753px - var(--scrollbar_width)); background-size: var(--row_image_size);} -#close_hover_border { top: 0px; left: calc(753px - var(--scrollbar_width)); background-size: var(--row_image_size);} -#close_hover_background { top: 20px; left: calc(753px - var(--scrollbar_width)); background-size: var(--row_image_size);} - - -/* CLOSE TAB BUTTON OPTIONS */ -#expand_hover_background { top: 0px; left: calc(var(--children_padding_left) - 18px); background-size: var(--row_image_size);} -#expand_closed_background { top: 0px; left: calc(var(--children_padding_left) - 18px); background-size: var(--row_image_size);} -#expand_open_background { top: 0px; left: -12px; background-size: var(--row_image_size);} - - -#tab_list_background { top: 835px; left: 50px; } - - - -#toolbar_groups_block { position: absolute; left: 20px; top: calc(var(--scrollbar_height) + var(--pin_height) + 32px); width: 19px; height: 800px; background-color: var(--group_list_background); border-right: 1px solid var(--group_list_borders); overflow: visible; } -#_gtetab_list { width: 200px; height: 20px; } -#_gtetab_list2 { width: 200px; height: 20px; } -#_tab_list2:hover { background-color: var(--group_list_button_hover_background); } - -#group_list_background { top: 835px; left: 20px; } -#group_list_borders { top: 631px; left: 20px; } -#group_list_default_font_color { top: 652px; left: 20px; } -#group_list_button_hover_background { top: 610px; left: 20px; } - - -/* MENU */ -#tabs_menu_border { top: 59px; left: 80px; } -#tabs_menu_background { top: 59px; left: 102px; } -#tabs_menu_font { top: 36px; left: 102px; } -#tabs_menu_hover_border { top: 14px; left: 80px; } -#tabs_menu_hover_background { top: 14px; left: 102px; } -#tabs_menu_separator { top: 36px; left: 80px; } - diff --git a/scripts/IO.js b/scripts/IO.js deleted file mode 100644 index f885d81..0000000 --- a/scripts/IO.js +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) 2017 kroppy. All rights reserved. -// Use of this source code is governed by a Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0) license -// that can be found at https://creativecommons.org/licenses/by-nc-nd/4.0/ - -// ********** KEYBOARD AND MOUSE *************** - -function BindTabsSwitchingToMouseWheel() { - // switch tabs with mouse scroll - $("#pin_list, .group").bind("mousewheel DOMMouseScroll", function(event) { - let prev = event.originalEvent.wheelDelta > 0 || event.originalEvent.detail < 0; - if (prev) { - ActivatePrevTab(); - } else { - ActivateNextTab(); - } - event.preventDefault(); - }); -} - -function SetIOEvents() { - if (!opt.switch_with_scroll) { - $("#pin_list").bind("mousewheel DOMMouseScroll", function(event) { - let direction = (event.originalEvent.wheelDelta > 0 || event.originalEvent.detail < 0) ? -1 : 1; - let speed = 0.1; - for (let t = 1; t < 40; t++) { - setTimeout(function() { - if (t < 30) { - speed = speed+0.1; // accelerate - } else { - speed = speed-0.3; // decelerate - } - $("#pin_list").scrollLeft($("#pin_list").scrollLeft()+(direction*speed)); - }, t); - } - }); - } - - // catch keyboard keys - $(document).keydown(function(event) { - if (MouseHoverOver == "pin_list") { - // ctrl+a to select all - if (event.ctrlKey && event.which == 65) { - $(".pin").addClass("selected_tab"); - } - // ctrl+i to invert selection - if (event.ctrlKey && event.which == 73) { - $(".pin").toggleClass("selected_tab"); - } - } - if (MouseHoverOver.match("g_|tab_list") !== null) { - // ctrl+a to select all - if (event.ctrlKey && event.which == 65) { - $("#ch"+active_group).children(".tab:visible").addClass("selected_tab"); - } - // ctrl+i to invert selection - if (event.ctrlKey && event.which == 73) { - $(".tab:visible").toggleClass("selected_tab"); - } - } - RefreshGUI(); - }); - - // remove middle mouse and set hiding menu - document.body.onmousedown = function(event) { - if (event.button == 1 && opt.close_with_MMB == true) { - event.preventDefault(); - } - if (event.button == 0 && !$(event.target).is(".menu_item")) { - $(".menu").hide(300); - } - }; -} diff --git a/scripts/backup.js b/scripts/backup.js index b14d465..f60b42b 100644 --- a/scripts/backup.js +++ b/scripts/backup.js @@ -3,31 +3,41 @@ // that can be found at https://creativecommons.org/licenses/by-nc-nd/4.0/ function ExportGroup(filename) { + if (opt.debug) { + console.log("function: ExportGroup, filename "+filename); + } let GroupToSave = { group: bggroups[active_group], folders: {}, tabs: [] }; - let lastId = parseInt($("#"+active_group+" .tab").last()[0].id); - $("#"+active_group+" .folder").each(function() { - if (bgfolders[this.id]) { - GroupToSave.folders[this.id] = bgfolders[this.id]; + document.querySelectorAll("#"+active_group+" .folder").forEach(function(s){ + if (bgfolders[s.id]) { + GroupToSave.folders[s.id] = bgfolders[s.id]; } - }) - $("#"+active_group+" .tab").each(function() { - chrome.tabs.get(parseInt(this.id), function(tab) { - if ((tab.url).startsWith("www") || (tab.url).startsWith("http") || (tab.url).startsWith("ftp")) { - (GroupToSave.tabs).push( - { - id: tab.id, - parent: $("#"+tab.id).parent().parent()[0].id, - index: $("#"+tab.id).index(), - expand: ($("#"+tab.id).is(".n") ? "n" : ($("#"+tab.id).is(".c") ? "c" : "o")), - url: tab.url - } - ); - } - if (tab.id == lastId) { - SaveFile(filename, GroupToSave); - } + }); + let Tabs = document.querySelectorAll("#"+active_group+" .tab"); + if (Tabs.length > 0) { + let lastId = parseInt(Tabs[Tabs.length-1].id); + Tabs.forEach(function(s){ + chrome.tabs.get(parseInt(s.id), function(tab) { + if ((tab.url).startsWith("www") || (tab.url).startsWith("http") || (tab.url).startsWith("ftp")) { + (GroupToSave.tabs).push( + { + id: tab.id, + parent: s.parentNode.parentNode.id, + index: Array.from(s.parentNode.children).indexOf(s), + expand: (s.classList.contains("c") ? "c" : (s.classList.contains("o") ? "o" : "")), + url: tab.url + } + ); + } + + if (tab.id == lastId) { + // if (opt.debug) { + // console.log(GroupToSave); + // } + SaveFile(filename, GroupToSave); + } + }); }); - }) + } } function ImportGroup() { let file = document.getElementById("file_import_group"); @@ -36,12 +46,12 @@ function ImportGroup() { fr.readAsText(file.files[0]); fr.onload = function() { let data = fr.result; - file.remove(); + file.parentNode.removeChild(file); let LoadedGroup = JSON.parse(data); let NewFolders = {}; let RefsTabs = {}; let NewTabs = []; - let NewGroupId = AddNewGroup({name: LoadedGroup.group.name, font: LoadedGroup.group.font}); + let NewGroupId = AddNewGroup(LoadedGroup.group.name, LoadedGroup.group.font); SetActiveGroup(NewGroupId, false, false); for (var folder in LoadedGroup.folders) { let newId = GenerateNewFolderID(); @@ -58,6 +68,13 @@ function ImportGroup() { RefsTabs[Tab.id] = new_tab.id; Tab.id = new_tab.id; NewTabs.push(Tab); + setTimeout(function() { + let nt = document.getElementById(new_tab.id); + let NewGroupTabs = document.getElementById("ct"+NewGroupId); + if (nt != null && NewGroupTabs != null) { + NewGroupTabs.appendChild(nt); + } + }, 1000); } if (NewTabs.length == LoadedGroup.tabs.length-1) { setTimeout(function() { @@ -89,10 +106,10 @@ function ExportSession(filename) { let ExportWindows = []; w.forEach(function(CWin) { if (CWin.tabs.length > 0) { - if (CWin.tabs.length > 100 && warn) { - alert(chrome.i18n.getMessage("warning_exporting_big_amount_of_tabs")); - warn = false; - } + // if (CWin.tabs.length > 100 && warn) { + // alert(chrome.i18n.getMessage("warning_exporting_big_amount_of_tabs")); + // warn = false; + // } windows[CWin.id]["id"] = CWin.id; windows[CWin.id]["tabs"] = []; CWin.tabs.forEach(function(CTab) { @@ -115,10 +132,10 @@ function ImportSession() { fr.readAsText(file.files[file.files.length-1]); fr.onload = function() { let data = fr.result; - file.remove(); + file.parentNode.removeChild(file); let LoadedWindows = JSON.parse(data); let RefsTabs = {}; - log(LoadedWindows); + if (opt.debug) console.log(LoadedWindows); LoadedWindows.forEach(function(LWin) { let NewTabs = []; let urls = []; @@ -152,15 +169,15 @@ function ImportSession() { } } function RearrangeTreeStructure(groups, folders, tabs) { // groups and folders are in object, just like bggroups and bgfolders, but tabs are in array of bgtreetabs objects - log("function: RearrangeTreeStructure"); + if (opt.debug) console.log("function: RearrangeTreeStructure"); chrome.tabs.query({currentWindow: true}, function(ChromeTabs) { - if (Object.keys(groups).length > 0) { + if (groups && Object.keys(groups).length > 0) { for (var group in groups) { bggroups[groups[group].id] = Object.assign({}, groups[group]); } AppendGroups(bggroups); } - if (Object.keys(folders).length > 0) { + if (folders && Object.keys(folders).length > 0) { for (var folder in folders) { bgfolders[folders[folder].id] = Object.assign({}, folders[folder]); } @@ -171,9 +188,13 @@ function RearrangeTreeStructure(groups, folders, tabs) { // groups and folders a if (Tab.parent == "pin_list") { chrome.tabs.update(Tab.id, {pinned: true}); } - if ($("#"+Tab.id)[0] && $("#ch"+Tab.parent)[0]) { - $("#ch"+Tab.parent).append($("#"+Tab.id)); - $("#"+Tab.id).addClass(Tab.expand); + let tb = document.getElementById(Tab.id); + let tbp = document.getElementById("ct"+Tab.parent); + if (tb != null && tbp != null) { + tbp.appendChild(tb); + if (Tab.expand != "") { + tb.classList.add(Tab.expand); + } } bgtabs[Tab.id] = {index: Tab.index, parent: Tab.parent, expand: Tab.expand}; }); @@ -189,21 +210,21 @@ function RearrangeTreeStructure(groups, folders, tabs) { // groups and folders a }); } function ImportMergeTabs() { - log("function: ImportMergeTabs"); + if (opt.debug) console.log("function: ImportMergeTabs"); let file = document.getElementById("file_import_merge_backup"); let fr = new FileReader(); if (file.files[0] == undefined) return; fr.readAsText(file.files[0]); fr.onload = function() { let data = fr.result; - file.remove(); + file.parentNode.removeChild(file); let lw = JSON.parse(data); let RefsWins = {}; let RefsTabs = {}; for (let LWI = 0; LWI < lw.length; LWI++) { // clear previous window ids lw[LWI].id = ""; } - log(lw); + if (opt.debug) console.log(lw); chrome.windows.getAll({windowTypes: ['normal'], populate: true}, function(cw) { for (let CWI = 0; CWI < cw.length; CWI++) { // loop Windows for (let LWI = 0; LWI < lw.length; LWI++) { // loop Loaded Windows @@ -219,17 +240,17 @@ function ImportMergeTabs() { } } } - log(tabsMatch); + if (opt.debug) console.log(tabsMatch); if (tabsMatch > lw[LWI].tabs.length*0.8) { lw[LWI].id = cw[CWI].id; break; } } } - log(lw); + if (opt.debug) console.log(lw); lw.forEach(function(w) { if (w.id == "") { // missing window, lets make one - log("missing window"); + if (opt.debug) console.log("missing window"); let NewTabs = []; let urls = []; (w.tabs).forEach(function(Tab) { @@ -261,7 +282,7 @@ function ImportMergeTabs() { } else { // window exists, lets add missing tabs - log("window exists"); + if (opt.debug) console.log("window exists"); let NewTabs = []; (w.tabs).forEach(function(Tab) { if (Tab.url != "") { // missing tab, lets make one diff --git a/scripts/chrome.js b/scripts/chrome.js index 455e7e6..3aa49ad 100644 --- a/scripts/chrome.js +++ b/scripts/chrome.js @@ -13,12 +13,13 @@ function StartChromeListeners() { }); } chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) { - log("message to sidebar "+CurrentWindowId+": "); - log(message); if (message.command == "backup_available") { - $("#button_load_bak"+message.bak).removeClass("disabled"); + if (opt.debug) console.log("message to sidebar "+CurrentWindowId+": message: "+message.command); + document.getElementById("button_load_bak"+message.bak).classList.remove("disabled"); } if (message.command == "drag_drop") { + if (opt.debug) console.log("message to sidebar "+CurrentWindowId+": message: "+message.command); + if (opt.debug) console.log(message); DragAndDrop.ComesFromWindowId = message.ComesFromWindowId; DragAndDrop.DragNodeClass = message.DragNodeClass; DragAndDrop.Depth = message.Depth; @@ -27,8 +28,11 @@ function StartChromeListeners() { DragAndDrop.TabsIds = message.TabsIds; DragAndDrop.TabsIdsParents = message.TabsIdsParents; DragAndDrop.TabsIdsSelected = message.TabsIdsSelected; + DropTargetsFront(undefined, true, false); } if (message.command == "dropped") { + if (opt.debug) console.log("message to sidebar "+CurrentWindowId+": message: "+message.command); + if (opt.debug) console.log(message); DragAndDrop.DroppedToWindowId = message.DroppedToWindowId; if (Object.keys(DragAndDrop.Folders).length > 0 && message.DroppedToWindowId != CurrentWindowId) { for (var folder in DragAndDrop.Folders) @@ -37,18 +41,25 @@ function StartChromeListeners() { } } } + if (message.command == "dragend") { + CleanUpDragClasses(); + } if (message.command == "reload_sidebar") { + if (opt.debug) console.log("message to sidebar "+CurrentWindowId+": message: "+message.command); + if (opt.debug) console.log(message); window.location.reload(); } if (message.command == "reload_options") { + if (opt.debug) console.log("message to sidebar "+CurrentWindowId+": message: "+message.command); chrome.runtime.sendMessage({command: "get_preferences"}, function(response) { opt = Object.assign({}, response); setTimeout(function() { RestorePinListRowSettings(); - }, 200); + }, 200); }); } if (message.command == "reload_theme") { + if (opt.debug) console.log("message to sidebar "+CurrentWindowId+": message: "+message.command); setTimeout(function() { chrome.runtime.sendMessage({command: "get_theme", windowId: CurrentWindowId}, function(response) { RestorePinListRowSettings(); @@ -58,110 +69,150 @@ function StartChromeListeners() { }, 300); } if (message.windowId == CurrentWindowId) { - switch(message.command) { - case "tab_created": // if set to treat unparented tabs as active tab's child - if (opt.append_orphan_tab == "as_child" && message.tab.openerTabId == undefined && $("#"+active_group+" .active_tab")[0]) { - message.tab.openerTabId = $("#"+active_group+" .active_tab")[0].id; + + // I WANT TO MOVE THIS LOGIC TO THE BACKGROUND SCRIPT! + + if (message.command == "tab_created") { // if set to treat unparented tabs as active tab's child + + if (opt.debug) console.log("tab_created: "+message.tabId); + if (opt.debug) console.log("tab is pinned: "+message.tab.pinned); + + if (message.parentTabId != undefined) { + AppendTab(message.tab, message.parentTabId, false, false, true, message.index, true, false, false, true, false); + } else { + if (opt.append_orphan_tab == "as_child" && message.tab.openerTabId == undefined && document.querySelector("#"+active_group+" .active_tab")) { + if (opt.debug) console.log("ignore orphan case, append tab as child"); + message.tab.openerTabId = document.querySelector("#"+active_group+" .active_tab").id; } if (message.tab.openerTabId) { // child case if (opt.append_child_tab == "after_active") { - AppendTab({ tab: message.tab, InsertAfterId: $("#"+active_group+" .active_tab")[0] ? $("#"+active_group+" .active_tab")[0].id : undefined, Append: false, Scroll: true }); + if (opt.debug) console.log("child case, tab will append after active"); + AppendTab(message.tab, false, false, document.querySelector("#"+active_group+" .active_tab") != null ? document.querySelector("#"+active_group+" .active_tab").id : false, false, false, true, false, false, true, false); } else { - if (opt.max_tree_depth < 0 || (opt.max_tree_depth > 0 && $("#"+message.tab.openerTabId).parents(".tab").length < opt.max_tree_depth)) { // append to tree + let Parents = GetParentsByClass(document.getElementById(message.tab.openerTabId), "tab"); + if (opt.max_tree_depth < 0 || (opt.max_tree_depth > 0 && Parents.length < opt.max_tree_depth)) { // append to tree if (opt.append_child_tab == "top") { - AppendTab({ tab: message.tab, ParentId: message.tab.openerTabId, Append: false, Scroll: true }); + if (opt.debug) console.log("child case, in tree limit, tab will append on top"); + AppendTab(message.tab, message.tab.openerTabId, false, false, (message.tab.pinned ? true : false), false, true, false, false, true, false); } if (opt.append_child_tab == "bottom") { - AppendTab({ tab: message.tab, ParentId: message.tab.openerTabId, Append: true, Scroll: true }); + if (opt.debug) console.log("child case, in tree limit, tab will append on bottom"); + AppendTab(message.tab, message.tab.openerTabId, false, false, true, false, true, false, false, true, false); } } - if (opt.max_tree_depth > 0 && $("#"+message.tab.openerTabId).parents(".tab").length >= opt.max_tree_depth) { // if reached depth limit of the tree + if (opt.max_tree_depth > 0 && Parents.length >= opt.max_tree_depth) { // if reached depth limit of the tree + if (opt.debug) console.log("child case, surpassed tree limit"); if (opt.append_child_tab_after_limit == "after") { - AppendTab({ tab: message.tab, InsertAfterId: message.tab.openerTabId, Append: true, Scroll: true }); + if (opt.debug) console.log("tab will append after active"); + AppendTab(message.tab, false, false, message.tab.openerTabId, true, false, true, false, false, true, false); } if (opt.append_child_tab_after_limit == "top") { - AppendTab({ tab: message.tab, ParentId: $("#"+message.tab.openerTabId).parent().parent()[0].id, Append: false, Scroll: true }); + if (opt.debug) console.log("tab will append on top"); + AppendTab(message.tab, document.getElementById(message.tab.openerTabId).parentNode.parentNode.id, false, false, (message.tab.pinned ? true : false), false, true, false, false, true, false); } if (opt.append_child_tab_after_limit == "bottom") { - AppendTab({ tab: message.tab, ParentId: $("#"+message.tab.openerTabId).parent().parent()[0].id, Append: true, Scroll: true }); + if (opt.debug) console.log("tab will append on bottom"); + AppendTab(message.tab, document.getElementById(message.tab.openerTabId).parentNode.parentNode.id, false, false, true, false, true, false, false, true, false); } } } - if (opt.max_tree_depth == 0) { // place tabs flat, (should I merge it with orphans case?) + if (opt.max_tree_depth == 0) { // place tabs flat + if (opt.debug) console.log("max_tree_depth is 0, tabs are placed on the same level"); if (opt.append_child_tab_after_limit == "after") { - AppendTab({ tab: message.tab, InsertAfterId: message.tab.openerTabId, Append: false, Scroll: true }); + if (opt.debug) console.log("tab will append after active"); + AppendTab(message.tab, false, false, message.tab.openerTabId, false, false, true, false, false, true, false); } if (opt.append_child_tab_after_limit == "top") { - AppendTab({ tab: message.tab, Append: false, Scroll: true }); + if (opt.debug) console.log("tab will append on top"); + AppendTab(message.tab, false, false, false, false, false, true, false, false, true, false); } if (opt.append_child_tab_after_limit == "bottom") { - AppendTab({ tab: message.tab, Append: true, Scroll: true }); + if (opt.debug) console.log("tab will append on bottom"); + AppendTab(message.tab, false, false, false, true, false, true, false, false, true, false); } } } else { // orphan case if (opt.append_orphan_tab == "after_active") { - AppendTab({ tab: message.tab, InsertAfterId: $("#"+active_group+" .active_tab")[0] ? $("#"+active_group+" .active_tab")[0].id : undefined, Append: false }); + AppendTab(message.tab, false, false, (document.querySelector("#"+active_group+" .active_tab") != null ? document.querySelector("#"+active_group+" .active_tab").id : undefined), (message.tab.pinned ? true : false), false, true, false, false, true, false); } if (opt.append_orphan_tab == "top") { - AppendTab({ tab: message.tab, Append: false }); + AppendTab(message.tab, false, false, false, false, false, true, false, false, true, false); } if (opt.append_orphan_tab == "bottom" || opt.append_orphan_tab == "as_child") { - AppendTab({ tab: message.tab, Append: true }); + AppendTab(message.tab, false, false, false, true, false, true, false, false, true, false); } } - if ($("#"+message.tab.openerTabId).is(".c")) { - $("#"+message.tab.openerTabId).removeClass("c").addClass("o"); + } + + if (message.tab.openerTabId) { // check if openerTabId is defined, if it's in DOM and if it's closed, then change it to open + let openerTab = document.querySelector(".c[id='"+message.tab.openerTabId+"']"); + if (openerTab != null) { + openerTab.classList.remove("c"); + openerTab.classList.add("o"); } - if (opt.syncro_tabbar_tabs_order) { - let TTtabsIndexes = $(".pin, .tab").map(function(){return parseInt(this.id);}).toArray(); - chrome.tabs.move(message.tab.id, {index: TTtabsIndexes.indexOf(message.tab.id)}); + } + 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)}); + } + RefreshExpandStates(); + schedule_update_data++; + RefreshGUI(); + RefreshCounters(); + return; + } + if (message.command == "tab_attached") { + if (opt.debug) console.log(message); + AppendTab(message.tab, message.ParentId, false, false, true, false, true, false, false, true, false); + RefreshGUI(); + return; + } + if (message.command == "tab_detached") { + let ctDetachedParent = document.getElementById(message.tabId).childNodes[4]; + if (ctDetachedParent != null) { + if (opt.promote_children_in_first_child == true && ctDetachedParent.childNodes.length > 1) { + let ctNewParent = document.getElementById(ctDetachedParent.firstChild.id).childNodes[4]; + ctDetachedParent.parentNode.parentNode.insertBefore(ctDetachedParent.firstChild, ctDetachedParent.parentNode); + while (ctDetachedParent.firstChild) { + ctNewParent.appendChild(ctDetachedParent.firstChild); + } + } else { + while (ctDetachedParent.firstChild) { + ctDetachedParent.parentNode.parentNode.insertBefore(ctDetachedParent.firstChild, ctDetachedParent.parentNode); + } } - RefreshExpandStates(); + } + RemoveTabFromList(message.tabId); + setTimeout(function() { schedule_update_data++; - RefreshGUI(); - RefreshCounters(); - break; - case "tab_attached": - AppendTab({tab: message.tab, ParentId: message.ParentId, Append: true}); - RefreshGUI(); - break; - case "tab_detached": - if ($(".tab#"+message.tabId)[0]) { - if (opt.promote_children == true) { - if (opt.promote_children_in_first_child == true && $("#ch"+message.tabId).children().length > 1) { - let FirstChild = $("#ch"+message.tabId).children()[0]; - $(FirstChild).insertAfter($("#"+message.tabId)); - $("#ch"+FirstChild.id).append($("#ch"+message.tabId).children()); - } else { - $("#ch"+message.tabId).children().insertAfter($("#"+message.tabId)); + }, 300); + RefreshGUI(); + return; + } + if (message.command == "tab_removed") { + if (opt.debug) console.log("tab_removed: "+message.tabId); + let mTab = document.getElementById(message.tabId); + if (mTab != null) { + let ctParent = mTab.childNodes[4]; + if (opt.debug) console.log("tab_removed, promote children: " +opt.promote_children); + if (opt.promote_children == true) { + if (opt.promote_children_in_first_child == true && ctParent.childNodes.length > 1) { + let ctNewParent = document.getElementById(ctParent.firstChild.id).childNodes[4]; + ctParent.parentNode.parentNode.insertBefore(ctParent.firstChild, ctParent.parentNode); + while (ctParent.firstChild) { + ctNewParent.appendChild(ctParent.firstChild); } } else { - $("#ch"+message.tabId).find(".tab").each(function() { - RemoveTabFromList(this.id); - }); - } - } - RemoveTabFromList(message.tabId); - setTimeout(function() { - schedule_update_data++; - }, 300); - RefreshGUI(); - break; - case "tab_removed": - if ($(".tab#"+message.tabId)[0]) { - if (opt.promote_children == true) { - if (opt.promote_children_in_first_child == true && $("#ch"+message.tabId).children().length > 1) { - let FirstChild = $("#ch"+message.tabId).children()[0]; - $(FirstChild).insertAfter($("#"+message.tabId)); - $("#ch"+FirstChild.id).append($("#ch"+message.tabId).children()); - } else { - $("#ch"+message.tabId).children().insertAfter($("#"+message.tabId)); + while (ctParent.firstChild) { + ctParent.parentNode.parentNode.insertBefore(ctParent.firstChild, ctParent.parentNode); } - } else { - $("#ch"+message.tabId).find(".tab").each(function() { - chrome.tabs.remove(parseInt(this.id)); - }); } + } else { + document.querySelectorAll("[id='"+message.tabId+"'] .tab").forEach(function(s) { + chrome.tabs.remove(parseInt(s.id)); + }); } RemoveTabFromList(message.tabId); RefreshExpandStates(); @@ -170,44 +221,48 @@ function StartChromeListeners() { }, 300); RefreshGUI(); RefreshCounters(); - break; - case "tab_activated": + } + return; + } + if (message.command == "tab_activated") { + SetActiveTab(message.tabId); + return; + } + if (message.command == "tab_attention") { + SetAttentionIcon(message.tabId); + return; + } + if (message.command == "tab_updated") { + if (message.changeInfo.favIconUrl != undefined || message.changeInfo.url != undefined) { setTimeout(function() { - SetActiveTab(message.tabId); - }, 200); - break; - case "tab_attention": - SetAttentionIcon(message.tabId); - break; - case "tab_updated": - if (message.changeInfo.favIconUrl != undefined || message.changeInfo.url != undefined) { - setTimeout(function() { - GetFaviconAndTitle(message.tabId, true); - }, 100); + GetFaviconAndTitle(message.tabId, true); + }, 100); + } + if (message.changeInfo.title != undefined) { + setTimeout(function() { + GetFaviconAndTitle(message.tabId, true); + }, 1000); + } + if (message.changeInfo.audible != undefined || message.changeInfo.mutedInfo != undefined) { + RefreshMediaIcon(message.tabId); + } + if (message.changeInfo.discarded != undefined) { + RefreshDiscarded(message.tabId); + } + if (message.changeInfo.pinned != undefined) { + let updateTab = document.getElementById(message.tabId); + if (updateTab != null && ( (message.tab.pinned && updateTab.classList.contains("tab")) || (!message.tab.pinned && updateTab.classList.contains("pin")) ) ) { + SetTabClass(message.tabId, message.tab.pinned); + schedule_update_data++; } - if (message.changeInfo.title != undefined) { - setTimeout(function() { - GetFaviconAndTitle(message.tabId, true); - }, 1000); - } - if (message.changeInfo.audible != undefined || message.changeInfo.mutedInfo != undefined) { - RefreshMediaIcon(message.tabId); - } - if (message.changeInfo.discarded != undefined) { - RefreshDiscarded(message.tabId); - } - if (message.changeInfo.pinned != undefined) { - if ((message.tab.pinned && $("#"+message.tabId).is(".tab")) || (!message.tab.pinned && $("#"+message.tabId).is(".pin"))) { - SetTabClass({ id: message.tabId, pin: message.tab.pinned }); - schedule_update_data++; - } - RefreshExpandStates(); - } - break; - case "remote_update": - RearrangeTreeStructure(message.groups, message.folders, message.tabs); - sendResponse(true); - break; + RefreshExpandStates(); + } + return; + } + if (message.command == "remote_update") { + RearrangeTreeStructure(message.groups, message.folders, message.tabs); + sendResponse(true); + return; } } diff --git a/scripts/drag_and_drop.js b/scripts/drag_and_drop.js deleted file mode 100644 index 45e8f0e..0000000 --- a/scripts/drag_and_drop.js +++ /dev/null @@ -1,412 +0,0 @@ -// Copyright (c) 2017 kroppy. All rights reserved. -// Use of this source code is governed by a Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0) license -// that can be found at https://creativecommons.org/licenses/by-nc-nd/4.0/ - -// ********** TABS EVENTS *************** - -function GetSelectedFolders() { - log("function: GetSelectedFolders"); - let res = {Folders: {}, FoldersSelected: [], TabsIds: [], TabsIdsParents: []}; - $("#"+active_group+" .selected_folder").each(function() { - res.FoldersSelected.push(this.id); - res.Folders[this.id] = Object.assign({}, bgfolders[this.id]); - if ($("#cf" + this.id).children().length > 0) { - $($("#cf" + this.id).find(".folder")).each(function() { - res.Folders[this.id] = Object.assign({}, bgfolders[this.id]); - }); - } - $($(this).find(".tab")).each(function() { - res.TabsIds.push(parseInt(this.id)); - res.TabsIdsParents.push($(this).parent()[0].id); - }); - }); - log(res); - return res; -} -function GetSelectedTabs() { - log("function: GetSelectedTabs"); - let res = {TabsIds: [], TabsIdsParents: [], TabsIdsSelected: []}; - $("#"+active_group+" .selected_tab").each(function() { - res.TabsIds.push(parseInt(this.id)); - res.TabsIdsParents.push($(this).parent()[0].id); - res.TabsIdsSelected.push(parseInt(this.id)); - if ($("#ch" + this.id).children().length > 0) { - $($("#ch" + this.id).find(".tab")).each(function() { - res.TabsIds.push(parseInt(this.id)); - res.TabsIdsParents.push($(this).parent()[0].id); - }); - } - }); - log(res); - return res; -} -function SetDragAndDropEvents() { - $(document).on("mouseleave", window, function(event) { - MouseHoverOver = ""; - }); - $(document).on("dragleave", window, function(event) { - MouseHoverOver = ""; - }); - $(document).on("dragleave", "body", function(event) { - MouseHoverOver = ""; - }); - $(document).on("dragover", "#toolbar_groups, #toolbar, #pin_list, .group", function(event) { - MouseHoverOver = this.id; - }); - $(document).on("mouseover", "#toolbar_groups, #toolbar, #pin_list, .group", function(event) { - MouseHoverOver = this.id; - }); - $(document).bind("drop dragover", function(event) { // PREVENT THE DEFAULT BROWSER DROP ACTION - event.preventDefault(); - }); - $(document).on("mousedown", ".drop_target", function(event) { // deny drag enter on drop_targets and allow clicks below them - $(".drop_target").css({"pointer-events": "none"}); - }); - $(document).on("dragenter", ".tab_header, .folder_header", function(event) { // allow drag enter on drop_targets - $(".drop_target").css({"pointer-events": "all"}); - }); - $(document).on("dragstart", ".tab_header, .folder_header", function(event) { // SET DRAG SOURCE - event.stopPropagation(); - event.originalEvent.dataTransfer.setDragImage(document.getElementById("DragImage"), 0, 0); - event.originalEvent.dataTransfer.setData("text", ""); - DragAndDrop.DroppedToWindowId = 0; - DragAndDrop.ComesFromWindowId = CurrentWindowId; - DragAndDrop.Depth = 0; - if ($(this)[0].classList[0] == "folder_header") { - DragAndDrop.DragNodeClass = "folder"; - if ($(this).parent().is(":not(.selected_folder)")) { - $(".selected_folder").addClass("selected_folder_frozen").removeClass("selected_folder"); - $(this).parent().addClass("selected_folder_temporarly").addClass("selected_folder"); - } - $(".selected_folder:not(:visible)").addClass("selected_folder_frozen").removeClass("selected_folder"); - let Folders = GetSelectedFolders(); - DragAndDrop.TabsIds = Object.assign([], Folders.TabsIds); - DragAndDrop.TabsIdsParents = Object.assign([], Folders.TabsIdsParents); - DragAndDrop.TabsIdsSelected = Object.assign([], []); - DragAndDrop.Folders = Object.assign({}, Folders.Folders); - DragAndDrop.FoldersSelected = Object.assign([], Folders.FoldersSelected); - } - if ($(this)[0].classList[0] == "tab_header") { - DragAndDrop.DragNodeClass = "tab"; - if ($(this).parent().is(".active_tab")) { - $(this).parent().addClass("selected_temporarly").addClass("selected_tab"); - } - $(".close").removeClass("show"); - $(".tab_header_hover").removeClass("tab_header_hover"); - if ($(this).parent().is(":not(.selected_tab)")) { - $(".selected_tab").addClass("selected_frozen").removeClass("selected_tab"); - $(this).parent().addClass("selected_temporarly").addClass("selected_tab"); - } - $(".selected_tab:not(:visible)").addClass("selected_frozen").removeClass("selected_tab"); - $("#"+active_group+" .selected_tab").find(".pin, .tab").each(function() { - if ($(this).parents(".pin, .tab").length > DragAndDrop.Depth) { - DragAndDrop.Depth = $(this).parents(".pin, .tab").length; - } - }); - DragAndDrop.Depth -= $(this).parents(".pin, .tab").length-1; - if (DragAndDrop.Depth < 0) { - DragAndDrop.Depth = 0; - } - let Tabs = GetSelectedTabs(); - DragAndDrop.TabsIds = Object.assign([], Tabs.TabsIds); - DragAndDrop.TabsIdsParents = Object.assign([], Tabs.TabsIdsParents); - DragAndDrop.TabsIdsSelected = Object.assign([], Tabs.TabsIdsSelected); - DragAndDrop.Folders = Object.assign({}, {}); - DragAndDrop.FoldersSelected = Object.assign([], []); - } - chrome.runtime.sendMessage({ - command: "drag_drop", - DragNodeClass: DragAndDrop.DragNodeClass, - TabsIds: DragAndDrop.TabsIds, - TabsIdsParents: DragAndDrop.TabsIdsParents, - TabsIdsSelected: DragAndDrop.TabsIdsSelected, - ComesFromWindowId: CurrentWindowId, - Depth: DragAndDrop.Depth, - Folders: DragAndDrop.Folders, - FoldersSelected: DragAndDrop.FoldersSelected - }); - }); - $(document).on("dragleave", ".highlighted_drop_target", function(event) { // REMOVE DROP TARGET WHEN DRAG LEAVES - $(".highlighted_drop_target").removeClass("highlighted_drop_target"); - }); - $(document).on("dragenter", ".pin>.drag_entered_top:not(.highlighted_drop_target), .pin>.drag_entered_bottom:not(.highlighted_drop_target)", function(event) { // SET DROP TARGET WHEN ENTERING PINS - event.stopPropagation(); - if (DragAndDrop.DragNodeClass == "tab") { - $(".highlighted_drop_target").removeClass("highlighted_drop_target"); - $(this).addClass("highlighted_drop_target"); - } - }); - $(document).on("dragenter", ".tab>.drag_entered_top:not(.highlighted_drop_target), .tab>.drag_entered_bottom:not(.highlighted_drop_target)", function(event) { // SET DROP TARGET WHEN ENTERING TABS - event.stopPropagation(); - if (DragAndDrop.DragNodeClass == "tab") { - if ($(".selected_tab:visible").find($(this)).length == 0) { - if (opt.max_tree_drag_drop && opt.max_tree_depth >= 0) { - if ($(this).parents(".tab").length + DragAndDrop.Depth-1 > opt.max_tree_depth) { - return; - } - } - $(".highlighted_drop_target").removeClass("highlighted_drop_target"); - $(this).addClass("highlighted_drop_target"); - } - } - }); - $(document).on("dragenter", ".tab>.drag_enter_center:not(.highlighted_drop_target)", function(event) { - event.stopPropagation(); - if (DragAndDrop.DragNodeClass == "tab") { - if ($(".selected_tab:visible").find($(this)).length == 0 && opt.max_tree_depth != 0) { - if (opt.max_tree_drag_drop && opt.max_tree_depth > 0) { - if ($(this).parents(".tab").length + DragAndDrop.Depth > opt.max_tree_depth) { - return; - } - } - $(".highlighted_drop_target").removeClass("highlighted_drop_target"); - $(this).addClass("highlighted_drop_target"); - } - } - }); - $(document).on("dragenter", ".folder>.drag_entered_top:not(.highlighted_drop_target), .folder>.drag_entered_bottom:not(.highlighted_drop_target), .folder>.drag_enter_center:not(.highlighted_drop_target)", function(event) { // SET DROP TARGET WHEN ENTERING FOLDERS - event.stopPropagation(); - if (DragAndDrop.DragNodeClass == "folder") { - $(".highlighted_drop_target").removeClass("highlighted_drop_target"); - $(this).addClass("highlighted_drop_target"); - } - }); - $(document).on("dragenter", ".folder>.drag_enter_center:not(.highlighted_drop_target)", function(event) { - event.stopPropagation(); - if (DragAndDrop.DragNodeClass == "tab") { - $(".highlighted_drop_target").removeClass("highlighted_drop_target"); - $(this).addClass("highlighted_drop_target"); - } - }); - $(document).on("dragover", "#pin_list, .group, .group_drag_box", function(event) { // SET DROP TARGET, PIN_LIST, TAB_LIST, GROUP OR GROUP_BUTTON - if (DragAndDrop.DragNodeClass != "group") { - if ($(".highlighted_drop_target").length == 0 && event.target.className == $(this)[0].className) { - $(this).addClass("highlighted_drop_target"); - } - } - }); - $(document).on("dragenter", ".drag_enter_center", function(event) { // TIMER FOR FOR AUTO EXPAND - event.stopPropagation(); - DragAndDrop.timeout = false; - setTimeout(function() { - DragAndDrop.timeout = true; - }, 1800); - }); - $(document).on("dragleave", ".drag_enter_center", function(event) { - DragAndDrop.timeout = false; - }); - $(document).on("dragover", ".c > .drag_enter_center", function(event) { - if (DragAndDrop.timeout && opt.open_tree_on_hover) { - $(this).parent().addClass("o").removeClass("c"); - DragAndDrop.timeout = false; - } - }); - $(document).on("drop", "*", function(event) { // DROP - chrome.runtime.sendMessage({command: "dropped", DroppedToWindowId: CurrentWindowId}); - event.stopPropagation(); - if (DragAndDrop.ComesFromWindowId == CurrentWindowId) { - DropToTarget($(".highlighted_drop_target")); - } else { - if (Object.keys(DragAndDrop.Folders).length > 0) { - for (var folder in DragAndDrop.Folders) { - bgfolders[DragAndDrop.Folders[folder].id] = Object.assign({}, DragAndDrop.Folders[folder]); - } - AppendFolders(bgfolders); - } - $(".selected_tab").addClass("selected_frozen").removeClass("selected_tab"); - let target = $(".highlighted_drop_target"); - let counter = 0; - (DragAndDrop.TabsIds).forEach(function(TabId) { - chrome.tabs.move(TabId, { windowId: CurrentWindowId, index: -1 }, function(MovedTab) { - if (browserId == "F") { // FIRFOX BUG 1398272 - HAVE TO REPLACE ORIGINAL ID - if ((DragAndDrop.TabsIdsParents).indexOf("ch"+DragAndDrop.TabsIds[counter]) != -1) { - DragAndDrop.TabsIdsParents[(DragAndDrop.TabsIdsParents).indexOf("ch"+DragAndDrop.TabsIds[counter])] = "ch"+MovedTab[0].id; - } - if ((DragAndDrop.TabsIdsSelected).indexOf(DragAndDrop.TabsIds[counter]) != -1) { - DragAndDrop.TabsIdsSelected[(DragAndDrop.TabsIdsSelected).indexOf(DragAndDrop.TabsIds[counter])] = MovedTab[0].id; - } - DragAndDrop.TabsIds[counter] = MovedTab[0].id; - } - counter++; - if (counter == DragAndDrop.TabsIds.length) { - setTimeout(function() { - (DragAndDrop.TabsIdsSelected).forEach(function(selectedTabId) { - if ($("#"+selectedTabId)[0]) { - $("#"+selectedTabId).addClass("selected_temporarly").addClass("selected_tab"); - } - }); - for (var tabsIdsIndex = 1; tabsIdsIndex < (DragAndDrop.TabsIds).length; tabsIdsIndex++) { - if ($("#"+DragAndDrop.TabsIds[tabsIdsIndex])[0] && $("#"+DragAndDrop.TabsIdsParents[tabsIdsIndex])[0]) { - $("#"+DragAndDrop.TabsIdsParents[tabsIdsIndex]).append($("#"+DragAndDrop.TabsIds[tabsIdsIndex])); - } - } - for (var FolderSelectedIndex = 0; FolderSelectedIndex < (DragAndDrop.FoldersSelected).length; FolderSelectedIndex++) { - if ($("#"+DragAndDrop.FoldersSelected[FolderSelectedIndex])[0]) { - $("#"+DragAndDrop.FoldersSelected[FolderSelectedIndex]).addClass("selected_folder_temporarly").addClass("selected_folder"); - } - } - DropToTarget(target); - }, 300); - } - }); - }); - } - $(".drop_target").css({"pointer-events": "none"}); - }); - $(document).on("dragend", ".tab_header, .folder_header", function(event) { // DETACH TABS - setTimeout(function() { - if (DragAndDrop.ComesFromWindowId == CurrentWindowId && DragAndDrop.DroppedToWindowId == 0) { - if ( (browserId == "F" && (event.screenX < event.view.mozInnerScreenX || event.screenX > (event.view.mozInnerScreenX + $(window).width()) || (event.screenY < event.view.mozInnerScreenY || event.screenY > (event.view.mozInnerScreenY + $(window).height())))) - || (browserId != "F" && (event.pageX < 0 || event.pageX > $(window).width() || event.pageY < 0 || event.pageY > $(window).height())) - ) { - if (DragAndDrop.DragNodeClass == "tab") { - DetachTabs(DragAndDrop.TabsIds, {}); - } - if (DragAndDrop.DragNodeClass == "folder") { - DetachTabs(DragAndDrop.TabsIds, DragAndDrop.Folders); - setTimeout(function() { - SaveFolders(); - }, 500); - } - } - } - }, 200); - $(".drop_target").css({"pointer-events": "none"}); - }); - $(document).on("dragstart", ".group_drag_box", function(event) { // DRAGGING GROUPS - event.originalEvent.dataTransfer.setData("null", "null"); - event.originalEvent.dataTransfer.setDragImage(document.getElementById("DragImage"), 0, 0); - DragAndDrop.DragNodeClass = "group"; - DragAndDrop.DragNode = $(this).parent(); - $(".highlighted_drop_target").removeClass("highlighted_drop_target"); - }); - $(document).on("dragenter", ".group_drag_box", function(event) { // WHEN DRAGGING THE GROUP, MOVE IT UP OR DOWN - if (DragAndDrop.DragNodeClass == "group") { - if (DragAndDrop.DragNode != undefined && $(this).parent() != DragAndDrop.DragNode) { - if ($(this).parent().index() <= DragAndDrop.DragNode.index()) { - DragAndDrop.DragNode.insertBefore($(this).parent()); - } else { - if ($(this).parent().index() > DragAndDrop.DragNode.index()) { - DragAndDrop.DragNode.insertAfter($(this).parent()); - } - } - $(".highlighted_drop_target").removeClass("highlighted_drop_target"); - } - } - }); - $(document).on("dragend", ".group_drag_box", function(event) { // WHEN FINISHED DRAGGING THE GROUP - DragAndDrop.DragNode = undefined; - UpdateBgGroupsOrder(); - $(".highlighted_drop_target").removeClass("highlighted_drop_target"); - RearrangeGroupsLists(); - $(".drop_target").css({"pointer-events": "none"}); - if (opt.syncro_tabbar_groups_tabs_order) { - schedule_rearrange_tabs++; - } - }); -} -function DropToTarget(TargetNode) { - if (DragAndDrop.DragNodeClass == "tab") { - if (TargetNode.parent().is(".pin")) { // dropped on pin - $(".selected_tab").each(function() { - SetTabClass({ id: this.id, pin: true }); - if (TargetNode.is(".drag_entered_top")) { - $(this).insertBefore(TargetNode.parent()); - } else { - $(this).insertAfter(TargetNode.parent()); - } - }); - } - if (TargetNode.is("#pin_list")) { // dropped on pin_list - $(".selected_tab").each(function() { - SetTabClass({ id: this.id, pin: true }); - }); - TargetNode.append($(".selected_tab")); - } - if (TargetNode.parent().is(".tab, .folder")) { // dropped on tab or folder - if (TargetNode.parent().is(".selected_tab")) { - TargetNode.parent().addClass("highlighted_selected").removeClass("selected_tab"); - } - $(".selected_tab").each(function() { - SetTabClass({ id: this.id, pin: false }); - }); - if (TargetNode.is(".drag_entered_top")) { - $($(".selected_tab").get().reverse()).insertBefore(TargetNode.parent()); - } - if (TargetNode.is(".drag_entered_bottom")) { - $($(".selected_tab").get().reverse()).insertAfter(TargetNode.parent()); - } - if (TargetNode.is(".drag_enter_center")) { - if (opt.append_child_tab == "bottom") { - $("#ch" + TargetNode[0].id.substr(2)).append($($(".selected_tab").get().reverse())); - } else { - $("#ch" + TargetNode[0].id.substr(2)).prepend($($(".selected_tab").get().reverse())); - } - } - } - if (TargetNode.is(".group")) { // dropped on group (tab list) - $(".selected_tab").each(function() { - SetTabClass({ id: this.id, pin: false }); - }); - $("#ch"+TargetNode[0].id).append($($(".selected_tab").get().reverse())); - } - if (TargetNode.is(".group_drag_box")) { // dropped on group button (group list) - $(".selected_tab").each(function() { - SetTabClass({ id: this.id, pin: false }); - }); - $("#ch"+TargetNode[0].id.substr(1)).append($($(".selected_tab").get().reverse())); - } - $(".highlighted_selected").addClass("selected_tab").removeClass("highlighted_selected"); - $(".selected_frozen").addClass("selected_tab").removeClass("selected_frozen"); - $(".selected_temporarly").removeClass("selected_tab").removeClass("selected_temporarly"); - } - if (DragAndDrop.DragNodeClass == "folder") { // dropped on group button (group list) - if (TargetNode.is(".group_drag_box")) { - $("#cf"+TargetNode[0].id.substr(1)).append($($(".selected_folder").get().reverse())); - } - if (TargetNode.parent().is(".folder")) { // dropped on folder - if (TargetNode.parent().is(".selected_folder")) { - TargetNode.parent().addClass("highlighted_selected").removeClass("selected_folder"); - } - if (TargetNode.is(".drag_entered_top")) { - $($(".selected_folder").get().reverse()).insertBefore(TargetNode.parent()); - } - if (TargetNode.is(".drag_entered_bottom")) { - $($(".selected_folder").get().reverse()).insertAfter(TargetNode.parent()); - } - if (TargetNode.is(".drag_enter_center")) { - if (opt.append_child_tab == "bottom") { - $("#cf" + TargetNode[0].id.substr(2)).append($($(".selected_folder").get().reverse())); - } else { - $("#cf" + TargetNode[0].id.substr(2)).prepend($($(".selected_folder").get().reverse())); - } - } - } - $(".highlighted_selected").addClass("selected_folder").removeClass("highlighted_selected"); - $(".selected_folder_frozen").addClass("selected_folder").removeClass("selected_folder_frozen"); - $(".selected_folder_temporarly").removeClass("selected_folder").removeClass("selected_folder_temporarly"); - setTimeout(function() { - SaveFolders(); - }, 300); - } - RefreshExpandStates(); - DragAndDrop.timeout = false; - RefreshGUI(); - RefreshCounters(); - - if (opt.syncro_tabbar_tabs_order) { - let TTtabsIndexes = $(".pin, .tab").map(function(){return parseInt(this.id);}).toArray(); - chrome.tabs.move(DragAndDrop.TabsIds, {index: TTtabsIndexes.indexOf(DragAndDrop.TabsIds[0])}); - setTimeout(function() { - schedule_rearrange_tabs++; - }, 500); - } - - setTimeout(function() { - schedule_update_data++; - }, 500); - TargetNode.removeClass("highlighted_drop_target"); - $(".tab_header_hover").removeClass("tab_header_hover"); - $(".folder_header").removeClass("folder_header_hover"); - $(".dragover_highlight").removeClass("dragover_highlight"); // this is group dragover indicator -} \ No newline at end of file diff --git a/scripts/events.js b/scripts/events.js new file mode 100644 index 0000000..9bbdc11 --- /dev/null +++ b/scripts/events.js @@ -0,0 +1,590 @@ +// Copyright (c) 2017 kroppy. All rights reserved. +// Use of this source code is governed by a Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0) license +// that can be found at https://creativecommons.org/licenses/by-nc-nd/4.0/ + +function SetEvents() { + let PinList = document.getElementById("pin_list"); + + if (!opt.switch_with_scroll) { + PinList.onmousewheel = function(event) { + let pinList = document.getElementById("pin_list"); + let direction = (event.wheelDelta > 0 || event.detail < 0) ? -1 : 1; + let speed = 0.1; + for (let t = 1; t < 40; t++) { + setTimeout(function() { + if (t < 30) { + speed = speed+0.1; // accelerate + } else { + speed = speed-0.3; // decelerate + } + pinList.scrollLeft = pinList.scrollLeft+(direction*speed); + }, t); + } + } + } + document.oncontextmenu = function(event){ + if (!event.ctrlKey) { + event.preventDefault(); + } + } + document.body.onresize = function(event) { + RefreshGUI(); + } + + // MOUSE DOWN EVENTS + document.body.onmousedown = function(event) { + if (event.which == 2) { + event.preventDefault(); + } + + if (event.which == 1 && event.target.classList.contains("menu_item") == false) { + HideMenus(); + } + event.stopImmediatePropagation(); + + if (event.which == 1) { + RemoveHeadersHoverClass(); + } + + } + // MOUSE DOWN EVENTS + document.body.onmousedown = function(event) { + + if (event.which == 2) { + event.preventDefault(); + } + + if (event.which == 1 && event.target.classList.contains("menu_item") == false) { + HideMenus(); + } + event.stopImmediatePropagation(); + + if (event.which == 1) { + RemoveHeadersHoverClass(); + } + + } + + // CONFIRM EDIT FOLDER + document.getElementById("folder_edit_confirm").onmousedown = function(event) { + if (event.which == 1) { + FolderRenameConfirm(); + } + } + + // DISCARD EDIT FOLDER + document.getElementById("folder_edit_discard").onmousedown = function(event) { + if (event.which == 1) { + HideRenameDialogs(); + } + } + + // CONFIRM EDIT GROUP + document.getElementById("group_edit_confirm").onmousedown = function(event) { + if (event.which == 1) { + GroupEditConfirm(); + } + } + // DISCARD EDIT GROUP + document.getElementById("group_edit_discard").onmousedown = function(event) { + if (event.which == 1) { + HideRenameDialogs(); + } + } + document.getElementById("folder_edit_name").onkeydown = function(event) { + if (event.keyCode == 13) { + FolderRenameConfirm(); + } + if (event.which == 27) { + HideRenameDialogs(); + } + } + document.getElementById("group_edit_name").onkeydown = function(event) { + if (event.keyCode == 13) { + GroupEditConfirm(); + } + if (event.which == 27) { + HideRenameDialogs(); + } + } + + PinList.onmousedown = function(event) { + if (event.which == 1 && event.target == this) { + DeselectFolders(); + DeselectTabs(); + HideMenus(); + } + if (event.which == 2 && event.target == this) { + ActionClickGroup(this, opt.midclick_group); + } + if (event.which == 3 && event.target == this) { + ShowFGlobalMenu(event); + } + } + PinList.ondragenter = function(event) { + // PIN,TAB==>PINLIST + if (event.target.id == "pin_list" && DragAndDrop.DragNodeClass == "tab") { + HighlightNode(this); + } + } + + // DOUBLE CLICK ACTION + PinList.ondblclick = function(event) { + if (event.target == this) { + ActionClickGroup(this, opt.dbclick_group); + } + } + + + // SHOW COLOR PICKER + document.getElementById("group_edit_font").onclick = function(event) { + if (event.which == 1) { + event.stopPropagation(); + let ColorPicker = document.getElementById("color_picker"); + ColorPicker.setAttribute("PickColor", this.id); + ColorPicker.value = "#"+RGBtoHex(this.style.backgroundColor); + ColorPicker.focus(); + ColorPicker.click(); + } + } + document.getElementById("color_picker").oninput = function(event) { + document.getElementById(this.getAttribute("PickColor")).style.backgroundColor = this.value; + } + + + + // CATCH KEYBOARD GLOBAL KEYS + document.body.onkeydown = function(event) { + // ctrl+a to select all + if (event.ctrlKey && event.which == 65) { + if (document.querySelector(".pin>.tab_header_hover") != null) { + document.querySelectorAll(".pin").forEach(function(s){ + s.classList.add("selected_tab"); + }); + } + if (document.querySelector("#"+active_group+" .tab>.tab_header_hover") != null) { + let rootId = document.querySelector("#"+active_group+" .tab>.tab_header_hover").parentNode.parentNode.parentNode.id; + document.querySelectorAll("#ct"+rootId+">.tab").forEach(function(s){ + s.classList.add("selected_tab"); + }); + } + } + // ctrl+i to invert selection + if (event.ctrlKey && event.which == 73) { + if (document.querySelector(".pin>.tab_header_hover") != null) { + document.querySelectorAll(".pin").forEach(function(s){ + s.classList.toggle("selected_tab"); + }); + } + if (document.querySelector("#"+active_group+" .tab>.tab_header_hover") != null) { + let rootId = document.querySelector("#"+active_group+" .tab>.tab_header_hover").parentNode.parentNode.parentNode.id; + document.querySelectorAll("#ct"+rootId+">.tab").forEach(function(s){ + s.classList.toggle("selected_tab"); + }); + } + } + // esc to deselect tabs + if (event.which == 27) { + DeselectTabs(); + DeselectFolders(); + } + // alt+g to toggle group bar + if (event.altKey && event.which == 71) { + GroupsToolbarToggle(); + } + RefreshGUI(); + } + + + document.body.ondragover = function(event) { + event.preventDefault(); + if (event.target.parentNode.classList.contains("c") && event.target.parentNode.classList.contains("dragged_tree") == false) { + if (DragAndDrop.timeout && opt.open_tree_on_hover) { + event.target.parentNode.classList.add("o"); + event.target.parentNode.classList.remove("c"); + DragAndDrop.timeout = false; + } + } + } + + document.ondrop = function(event) { + if (opt.debug) { + console.log("drop"); + } + DragAndDrop.DroppedToWindowId = CurrentWindowId; + let target = document.querySelector(".highlighted_drop_target"); + event.preventDefault(); + if (DragAndDrop.ComesFromWindowId == CurrentWindowId) { + let selected = (document.querySelectorAll(".selected_tab").length > 0 ? document.querySelectorAll(".selected_tab") : (document.querySelectorAll(".selected_folder").length > 0 ? document.querySelectorAll(".selected_folder") : document.querySelectorAll(".dragged_group_button"))); + DropToTarget(target, selected); + } else { + if (Object.keys(DragAndDrop.Folders).length > 0) { + for (var folder in DragAndDrop.Folders) { + bgfolders[DragAndDrop.Folders[folder].id] = Object.assign({}, DragAndDrop.Folders[folder]); + } + AppendFolders(bgfolders); + } + let currentlySelected = document.querySelectorAll(".selected_tab"); + currentlySelected.forEach(function(s){ + s.classList.add("selected_frozen"); + s.classList.remove("selected_tab"); + s.classList.remove("selected_last"); + }); + let counter = 0; + (DragAndDrop.TabsIds).forEach(function(TabId) { + if (opt.debug) console.log("DragAndDrop: will now move tab: "+TabId); + chrome.tabs.move(TabId, { windowId: CurrentWindowId, index: -1 }, function(MovedTab) { + if (browserId == "F") { // MOZILLA BUG 1398272 + let MovedTabId = MovedTab[0] != undefined ? MovedTab[0].id : (MovedTab.id != undefined ? MovedTab.id : TabId); + if ((DragAndDrop.TabsIdsParents).indexOf("ct"+DragAndDrop.TabsIds[counter]) != -1) { // MOZILLA BUG 1398272 + DragAndDrop.TabsIdsParents[(DragAndDrop.TabsIdsParents).indexOf("ct"+DragAndDrop.TabsIds[counter])] = "ct"+MovedTabId; // MOZILLA BUG 1398272 + } // MOZILLA BUG 1398272 + if ((DragAndDrop.TabsIdsSelected).indexOf(DragAndDrop.TabsIds[counter]) != -1) { // MOZILLA BUG 1398272 + DragAndDrop.TabsIdsSelected[(DragAndDrop.TabsIdsSelected).indexOf(DragAndDrop.TabsIds[counter])] = MovedTabId; // MOZILLA BUG 1398272 + } // MOZILLA BUG 1398272 + DragAndDrop.TabsIds[counter] = MovedTabId; // MOZILLA BUG 1398272 + } // MOZILLA BUG 1398272 + counter++; + if (counter == DragAndDrop.TabsIds.length) { + console.log(DragAndDrop); + setTimeout(function() { + (DragAndDrop.TabsIdsSelected).forEach(function(selectedTabId) { + let selectedTab = document.getElementById(selectedTabId); + if (selectedTab != null) { + selectedTab.classList.add("selected_temporarly"); + selectedTab.classList.add("selected_tab"); + } + }); + for (var tabsIdsIndex = 1; tabsIdsIndex < (DragAndDrop.TabsIds).length; tabsIdsIndex++) { + let DTab = document.getElementById(DragAndDrop.TabsIds[tabsIdsIndex]); + let DTabParent = document.getElementById(DragAndDrop.TabsIdsParents[tabsIdsIndex]); + if (DTab != null && DTabParent != null) { + DTabParent.appendChild(DTab); + } + } + for (var FolderSelectedIndex = 0; FolderSelectedIndex < (DragAndDrop.FoldersSelected).length; FolderSelectedIndex++) { + let Folder = document.getElementById(DragAndDrop.FoldersSelected[FolderSelectedIndex]); + if (Folder != null) { + Folder.classList.add("selected_folder_temporarly"); + Folder.classList.add("selected_folder"); + } + } + let selected = (document.querySelectorAll(".selected_tab").length > 0 ? document.querySelectorAll(".selected_tab") : (document.querySelectorAll(".selected_folder").length > 0 ? document.querySelectorAll(".selected_folder") : document.querySelectorAll(".dragged_group_button"))); + DropToTarget(target, selected); + }, 300); + } + }); + }); + } + // event.dataTransfer.setData("folders", test_data); + // let folders = event.dataTransfer.getData("folders"); + } + document.ondragleave = function(event) { + if (opt.debug) { + console.log("global dragleave"); + } + if (event.target.classList) { + if (event.target.classList.contains("highlighted_drop_target") || event.target.classList.contains("drop_target")) { + event.target.classList.remove("highlighted_drop_target"); + } + if (event.target.classList.contains("drag_enter_center")) { + DragAndDrop.timeout = false; + } + } + } + + document.ondragend = function(event) { + if (opt.debug) { + console.log("document dragend"); + console.log(event); + } + + + // DETACHING TEMPORARILY DISABLED PLEASE USE MENU OR TOOLBAR! + + // if (DragAndDrop.ComesFromWindowId == CurrentWindowId && DragAndDrop.DroppedToWindowId == 0) { + // if ((browserId == "F" && ( event.screenX < event.view.mozInnerScreenX || event.screenX > (event.view.mozInnerScreenX + window.innerWidth) || event.screenY < event.view.mozInnerScreenY || event.screenY > (event.view.mozInnerScreenY + window.innerHeight)))|| (browserId != "F" && (event.pageX < 0 || event.pageX > window.outerWidth || event.pageY < 0 || event.pageY > window.outerHeight))) { + // if (opt.debug) console.log("dragged outside sidebar"); + // if (DragAndDrop.DragNodeClass == "tab") { + // Detach(DragAndDrop.TabsIds, {}); + // } + // if (DragAndDrop.DragNodeClass == "folder") { + // Detach(DragAndDrop.TabsIds, DragAndDrop.Folders); + // setTimeout(function() { + // SaveFolders(); + // }, 500); + // } + // } + // } + CleanUpDragClasses(); + chrome.runtime.sendMessage({command: "dragend"}); + } +} + + +function BindTabsSwitchingToMouseWheel(Id) { + document.getElementById(Id).onmousewheel = function(event) { + event.preventDefault(); + let prev = event.wheelDelta > 0 || event.detail < 0; + if (prev) { + ActivatePrevTab(); + } else { + ActivateNextTab(); + } + } +} + +function RemoveHeadersHoverClass() { + document.querySelectorAll(".folder_header_hover, .tab_header_hover").forEach(function(s){ + s.classList.remove("folder_header_hover"); + s.classList.remove("tab_header_hover"); + }); +} + +function DropToTarget(TargetNode, selected) { + if (opt.debug) console.log("function: DropToTarget"); + if (TargetNode != null && selected.length > 0) { + if (DragAndDrop.DragNodeClass == "tab") { + if (TargetNode.parentNode.classList.contains("pin")) { // dropped on pin + if (TargetNode.classList.contains("drag_entered_top")) { + selected.forEach(function(s){ + SetTabClass(s.id, true); + TargetNode.parentNode.parentNode.insertBefore(s, TargetNode.parentNode); + }); + } else { + if (TargetNode.parentNode.nextSibling != null) { + for (let i = selected.length-1; i >= 0; i--) { + SetTabClass(selected[i].id, true); + TargetNode.parentNode.parentNode.insertBefore(selected[i], TargetNode.parentNode.nextSibling); + } + } else { + selected.forEach(function(s){ + SetTabClass(s.id, true); + TargetNode.parentNode.parentNode.appendChild(s); + }); + } + } + } + if (TargetNode.id == "pin_list") { // dropped on pin_list + document.querySelectorAll(".selected_tab").forEach(function(s){ + SetTabClass(s.id, true); + TargetNode.appendChild(s); + }); + } + if (TargetNode.parentNode.classList.contains("tab") || TargetNode.parentNode.classList.contains("folder")) { // dropped on tab or folder + selected.forEach(function(s){ + SetTabClass(s.id, false); + }); + if (TargetNode.classList.contains("drag_entered_top")) { + selected.forEach(function(s){ + TargetNode.parentNode.parentNode.insertBefore(s, TargetNode.parentNode); + }); + } + if (TargetNode.classList.contains("drag_entered_bottom")) { + if (TargetNode.parentNode.nextSibling != null) { + for (let i = selected.length-1; i >= 0; i--) { + TargetNode.parentNode.parentNode.insertBefore(selected[i], TargetNode.parentNode.nextSibling); + } + } else { + selected.forEach(function(s){ + TargetNode.parentNode.parentNode.appendChild(s); + }); + } + } + if (TargetNode.classList.contains("drag_enter_center")) { + let newParent = document.getElementById("ct" + TargetNode.id.substr(2)); + if (opt.append_child_tab == "bottom") { + selected.forEach(function(s){ + newParent.appendChild(s); + }); + } else { + for (let i = selected.length-1; i >= 0; i--) { + newParent.prepend(selected[i]); + } + } + } + } + if (TargetNode.classList.contains("group")) { // dropped on group (tab list) + selected.forEach(function(s){ + SetTabClass(s.id, false); + }); + let newParent = document.getElementById("ct" + TargetNode.id); + selected.forEach(function(s){ + newParent.appendChild(s); + }); + } + if (TargetNode.classList.contains("group_drag_box")) { // dropped on group button (group list) + selected.forEach(function(s){ + SetTabClass(s.id, false); + }); + + let newParent = document.getElementById("ct" + TargetNode.id.substr(1)); + selected.forEach(function(s){ + newParent.appendChild(s); + }); + } + } + if (DragAndDrop.DragNodeClass == "folder") { // dropped on group button (group list) + if (opt.debug) console.log("DragNodeClass is folder"); + if (TargetNode.classList.contains("group")) { // dropped on group (tab list) + let newParent = document.getElementById("cf" + TargetNode.id); + selected.forEach(function(s){ + newParent.appendChild(s); + }); + } + if (TargetNode.classList.contains("group_drag_box")) { // dropped on group button (group list) + let newParent = document.getElementById("cf" + TargetNode.id.substr(1)); + selected.forEach(function(s){ + newParent.appendChild(s); + }); + } + if (TargetNode.parentNode.classList.contains("folder")) { // dropped on folder + if (TargetNode.classList.contains("drag_entered_top")) { + selected.forEach(function(s){ + TargetNode.parentNode.parentNode.insertBefore(s, TargetNode.parentNode); + }); + } + if (TargetNode.classList.contains("drag_entered_bottom")) { + if (TargetNode.parentNode.nextSibling != null) { + for(let i = selected.length-1; i >= 0; i--) { + TargetNode.parentNode.parentNode.insertBefore(selected[i], TargetNode.parentNode.nextSibling); + } + } else { + selected.forEach(function(s){ + TargetNode.parentNode.parentNode.appendChild(s); + }); + } + } + if (TargetNode.classList.contains("drag_enter_center")) { + let newParent = document.getElementById("cf" + TargetNode.id.substr(2)); + if (opt.append_child_tab == "bottom") { + selected.forEach(function(s){ + newParent.appendChild(s); + }); + } else { + for (let i = selected.length-1; i >= 0; i--) { + newParent.prepend(selected[i]); + } + } + } + } + setTimeout(function() { + SaveFolders(); + }, 300); + } + + if (TargetNode.parentNode.classList.contains("group_button") && DragAndDrop.DragNodeClass == "group") { + if (TargetNode.classList.contains("group_button_drag_entered_top")) { + TargetNode.parentNode.parentNode.insertBefore(selected[0], TargetNode.parentNode); + } else { + if (TargetNode.parentNode.nextSibling != null) { + TargetNode.parentNode.parentNode.insertBefore(selected[0], TargetNode.parentNode.nextSibling); + } else { + TargetNode.parentNode.parentNode.appendChild(selected[0]); + } + } + UpdateBgGroupsOrder(); + RearrangeGroupsLists(); + if (opt.syncro_tabbar_groups_tabs_order) { + schedule_rearrange_tabs++; + } + } + + if (opt.syncro_tabbar_tabs_order && DragAndDrop.TabsIds[0] != undefined) { + let tabIds = Array.prototype.map.call(document.querySelectorAll(".pin, .tab"), function(s){ + return parseInt(s.id); + }); + if (opt.debug) console.log("After DropToTarget, will Syncro tabbar tabs order, TabsIds array is:"); + if (opt.debug) console.log(DragAndDrop.TabsIds); + chrome.tabs.move(DragAndDrop.TabsIds, {index: tabIds.indexOf(DragAndDrop.TabsIds[0])}); + setTimeout(function() { + schedule_rearrange_tabs++; + }, 500); + } + } + DragAndDrop.timeout = false; + setTimeout(function() { + EmptyDragAndDrop(); + RefreshExpandStates(); + RefreshCounters(); + RefreshGUI(); + schedule_update_data++; + }, 100); + + CleanUpDragClasses(); + +} + +function DropTargetsFront(ExcludeNode, tabs, groups) { + if (ExcludeNode == undefined) { + ExcludeNode = {parentNode: {childNodes: [{id: "x"}, {id: "x"}, {id: "x"}], id: "x"}}; + } + if (tabs) { + document.querySelectorAll("#"+active_group+" .drag_enter_center:not(#"+ExcludeNode.parentNode.childNodes[0].id+")").forEach(function(s){ + s.style.zIndex = 9911; + }); + document.querySelectorAll("#"+active_group+" .drag_enter_center:not(#"+ExcludeNode.parentNode.childNodes[0].id+")").forEach(function(s){ + s.style.zIndex = 9911; + }); + document.querySelectorAll(".drag_entered_top:not(#"+ExcludeNode.parentNode.childNodes[1].id+")").forEach(function(s){ + s.style.zIndex = 9915; + }); + document.querySelectorAll(".drag_entered_bottom:not(#"+ExcludeNode.parentNode.childNodes[2].id+")").forEach(function(s){ + s.style.zIndex = 9920; + }); + } + if (groups) { + document.querySelectorAll(".group_button:not(#"+ExcludeNode.parentNode.id+") .group_drag_box").forEach(function(s){ + s.style.zIndex = -1; + }); + } +} + + +function CleanUpDragClasses() { + document.querySelectorAll(".highlighted_drop_target").forEach(function(s){ + s.classList.remove("highlighted_drop_target"); + }); + document.querySelectorAll(".highlighted_selected").forEach(function(s){ + s.classList.add("selected_tab"); + s.classList.remove("highlighted_selected"); + }); + document.querySelectorAll(".selected_frozen").forEach(function(s){ + s.classList.add("selected_tab"); + s.classList.remove("selected_frozen"); + }); + document.querySelectorAll(".selected_temporarly").forEach(function(s){ + s.classList.remove("selected_tab"); + s.classList.remove("selected_temporarly"); + }); + document.querySelectorAll(".highlighted_selected").forEach(function(s){ + s.classList.add("selected_folder"); + s.classList.remove("highlighted_selected"); + }); + document.querySelectorAll(".selected_folder_frozen").forEach(function(s){ + s.classList.add("selected_folder"); + s.classList.remove("selected_folder_frozen"); + }); + document.querySelectorAll(".selected_folder_temporarly").forEach(function(s){ + s.classList.remove("selected_folder"); + s.classList.remove("selected_folder_temporarly"); + }); + document.querySelectorAll(".tab_header_hover").forEach(function(s){ + s.classList.remove("tab_header_hover"); + }); + document.querySelectorAll(".folder_header").forEach(function(s){ + s.classList.remove("folder_header_hover"); + }); + document.querySelectorAll(".dragged_group_button").forEach(function(s){ // dragged group button + s.classList.remove("dragged_group_button"); + }); + document.querySelectorAll(".dragged_tree").forEach(function(s){ + s.classList.remove("dragged_tree"); + }); + document.querySelectorAll(".dragged_selected").forEach(function(s){ + s.classList.remove("dragged_selected"); + }); + document.querySelectorAll(".drop_target").forEach(function(s){ + s.style.zIndex = ""; + }); +} diff --git a/scripts/folders.js b/scripts/folders.js index bd86d59..d7d8f33 100644 --- a/scripts/folders.js +++ b/scripts/folders.js @@ -2,194 +2,413 @@ // Use of this source code is governed by a Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0) license // that can be found at https://creativecommons.org/licenses/by-nc-nd/4.0/ - -function AddNewFolder(p) { +function AddNewFolder(ParentId, Name, Index, ExpandState) { var newId = GenerateNewFolderID(); - bgfolders[newId] = { id: newId, parent: (p.ParentId ? p.ParentId : ""), index: (p.index ? p.index : 0), name: (p.name ? p.name : caption_noname_group), expand: (p.expand ? p.expand : "n") }; - AppendFolder({id: newId, ParentId: (p.ParentId ? p.ParentId : ""), name: caption_noname_group}); + bgfolders[newId] = { id: newId, parent: (ParentId ? ParentId : ""), index: (Index ? Index : 0), name: (Name ? Name : caption_noname_group), expand: (ExpandState ? ExpandState : "") }; + AppendFolder(newId, caption_noname_group, (ParentId ? ParentId : ""), undefined, true); SaveFolders(); RefreshCounters(); + RefreshExpandStates(); return newId; } -function AppendFolder(param) { - if ($("#"+param.id).length == 0) { - var fd = document.createElement("div"); fd.className = "folder "; if (param.expand) { fd.className += param.expand } fd.id = param.id;// FOLDER - var dc = document.createElement("div"); dc.className = "drop_target drag_enter_center"; dc.id = "dc"+param.id; fd.appendChild(dc); // DROP TARGET CENTER - var dt = document.createElement("div"); dt.className = "drop_target drag_entered_top"; dt.id = "du"+param.id; fd.appendChild(dt); // DROP TARGET TOP - var db = document.createElement("div"); db.className = "drop_target drag_entered_bottom"; db.id = "dd"+param.id; fd.appendChild(db); // DROP TARGET BOTTOM - var fh = document.createElement("div"); fh.className = opt.always_show_close ? "folder_header close_show" : "folder_header"; fh.id = "folder_header"+param.id; fh.draggable = true; fd.appendChild(fh); // HEADER - var ex = document.createElement("div"); ex.className = "folder_icon"; ex.id = "fop"+param.id; fh.appendChild(ex); - var ft = document.createElement("div"); ft.className = "folder_title"; ft.id = "folder_title"+param.id; ft.textContent = param.name; fh.appendChild(ft); // TITLE - var cf = document.createElement("div"); cf.className = "children"; cf.id = "cf"+param.id; fd.appendChild(cf); - var ch = document.createElement("div"); ch.className = "children"; ch.id = "ch"+param.id; fd.appendChild(ch); + +function AppendFolder(folderId, Name, ParentId, Expand, SetEvents) { + if (document.getElementById(folderId) == null) { + var fd = document.createElement("div"); fd.className = "folder "; if (Expand) { fd.className += Expand } fd.id = folderId;// FOLDER + var dc = document.createElement("div"); dc.className = "drop_target drag_enter_center"; dc.id = "dc"+folderId; fd.appendChild(dc); // DROP TARGET CENTER + var du = document.createElement("div"); du.className = "drop_target drag_entered_top"; du.id = "du"+folderId; fd.appendChild(du); // DROP TARGET TOP + var dd = document.createElement("div"); dd.className = "drop_target drag_entered_bottom"; dd.id = "dd"+folderId; fd.appendChild(dd); // DROP TARGET BOTTOM + var fh = document.createElement("div"); fh.className = (opt.always_show_close && !opt.never_show_close) ? "folder_header close_show" : "folder_header"; fh.id = "folder_header"+folderId; if (SetEvents) {fh.draggable = true;} fd.appendChild(fh); // HEADER + var ex = document.createElement("div"); ex.className = "folder_icon"; ex.id = "fop"+folderId; fh.appendChild(ex); + var ft = document.createElement("div"); ft.className = "folder_title"; ft.id = "folder_title"+folderId; ft.textContent = Name; fh.appendChild(ft); // TITLE + var cf = document.createElement("div"); cf.className = "children_folders"; cf.id = "cf"+folderId; fd.appendChild(cf); + var ct = document.createElement("div"); ct.className = "children_tabs"; ct.id = "ct"+folderId; fd.appendChild(ct); if (!opt.never_show_close) { - var cl = document.createElement("div"); cl.className = "close"; cl.id = "close"+param.id; fh.appendChild(cl); // CLOSE BUTTON - var ci = document.createElement("div"); ci.className = "close_img"; ci.id = "close_img"+param.id; cl.appendChild(ci); + var cl = document.createElement("div"); cl.className = "close"; cl.id = "close"+folderId; fh.appendChild(cl); // CLOSE BUTTON + var ci = document.createElement("div"); ci.className = "close_img"; ci.id = "close_img"+folderId; cl.appendChild(ci); } - if (param.ParentId == "" || param.ParentId == undefined || $("#cf"+param.ParentId).length == 0) { - $("#cf"+active_group).append(fd); + + if (SetEvents) { + ct.ondblclick = function(event) { + if (event.target == this) { + ActionClickGroup(this.parentNode, opt.dbclick_group); + } + } + cf.ondblclick = function(event) { + if (event.target == this) { + ActionClickGroup(this.parentNode, opt.dbclick_group); + } + } + + cf.onmousedown = function(event) { + if (event.target == this) { + if (event.which == 1) { + DeselectFolders(); + DeselectTabs(); + } + if (event.which == 2 && event.target == this) { + event.stopImmediatePropagation(); + ActionClickGroup(this.parentNode, opt.midclick_group); + } + if (event.which == 3) { + ShowFGlobalMenu(event); + } + } + } + ct.onmousedown = function(event) { + if (event.target == this) { + if (event.which == 1) { + DeselectFolders(); + DeselectTabs(); + } + if (event.which == 2 && event.target == this) { + event.stopImmediatePropagation(); + ActionClickGroup(this.parentNode, opt.midclick_group); + } + if (event.which == 3) { + ShowFGlobalMenu(event); + } + } + } + + if (!opt.never_show_close) { + cl.onmousedown = function(event) { + event.stopImmediatePropagation(); + if (event.which != 3) { + RemoveFolder(this.parentNode.parentNode.id); + } + } + cl.onmouseenter = function(event) { + this.classList.add("close_hover"); + } + cl.onmouseleave = function(event) { + this.classList.remove("close_hover"); + } + } + fh.onmousedown = function(event) { + if (document.getElementById("main_menu").style.top != "-1000px") { + HideMenus(); + } + // SELECT FOLDER + if (event.which == 1 && !event.shiftKey) { + DeselectTabs(); + if (!event.ctrlKey) { + DeselectFolders(); + } + event.target.parentNode.parentNode.classList.toggle("selected_folder"); + } + if (event.which == 2) { + event.preventDefault(); + ActionClickFolder(this.parentNode, opt.midclick_folder); + } + // SHOW FOLDER MENU + if (event.which == 3) { + ShowFolderMenu(this.parentNode, event); + } + } + // edit folder + fh.ondblclick = function(event) { + if (event.which == 1 && !event.shiftKey && !event.ctrlKey && (event.target.classList.contains("folder_title") || event.target.classList.contains("folder_header"))) { + // if (event.which == 1) { + // ShowRenameFolderDialog(this.parentNode.id); + ActionClickFolder(this.parentNode, opt.dbclick_folder); + } + } + fh.ondragstart = function(event) { // DRAG START + event.stopPropagation(); + event.dataTransfer.setDragImage(document.getElementById("DragImage"), 0, 0); + event.dataTransfer.setData("text", ""); + // event.dataTransfer.setData("TTSourceWindowId", CurrentWindowId); + CleanUpDragClasses(); + EmptyDragAndDrop(); + + if (opt.debug) console.log("started dragging folder"); + if (opt.debug) console.log(DragAndDrop.DragNodeClass); + + DropTargetsFront(this, true, false); + + if (this.parentNode.classList.contains("selected_folder") == false) { + if (opt.debug) console.log(this.parentNode.classList); + document.querySelectorAll(".selected_folder").forEach(function(s){ + s.classList.add("selected_folder_frozen"); + s.classList.remove("selected_folder"); + }); + this.parentNode.classList.add("selected_folder_temporarly"); + this.parentNode.classList.add("selected_folder"); + } else { + document.querySelectorAll(".group:not(#"+active_group+") .selected_folder").forEach(function(s){ + s.classList.add("selected_folder_frozen"); + s.classList.remove("selected_folder"); + }); + } + RemoveHeadersHoverClass(); + // let test_data = []; + document.querySelectorAll("[id='"+this.parentNode.id+"'], [id='"+this.parentNode.id+"'] .folder, [id='"+this.parentNode.id+"'] .tab").forEach(function(s){ + s.classList.add("dragged_tree"); + }); + document.querySelectorAll(".selected_tab, .selected_tab .tab, .selected_folder, .selected_folder .folder").forEach(function(s){ + s.classList.add("dragged_selected"); + // test_data.push(s.id); + }); + let Folders = GetSelectedFolders(); + + document.querySelectorAll("[id='"+this.parentNode.id+"'], [id='"+this.parentNode.id+"'] .folder, [id='"+this.parentNode.id+"'] .tab").forEach(function(s){ + s.classList.add("dragged_tree"); + }); + document.querySelectorAll(".selected_tab, .selected_tab .tab, .selected_folder, .selected_folder .folder").forEach(function(s){ + s.classList.add("dragged_selected"); + }); + + if (opt.max_tree_drag_drop_folders) { + document.querySelectorAll(".dragged_tree .folder").forEach(function(s){ + let parents = GetParentsByClass(s.parentNode, "dragged_tree"); + if (parents.length > DragAndDrop.Depth) { + DragAndDrop.Depth = parents.length; + } + }); + } else { + DragAndDrop.Depth = -1; + } + + DragAndDrop.DragNodeClass = "folder"; + DragAndDrop.TabsIds = Object.assign([], Folders.TabsIds); + DragAndDrop.TabsIdsParents = Object.assign([], Folders.TabsIdsParents); + DragAndDrop.Folders = Object.assign({}, Folders.Folders); + DragAndDrop.FoldersSelected = Object.assign([], Folders.FoldersSelected); + DragAndDrop.ComesFromWindowId = CurrentWindowId; + + chrome.runtime.sendMessage({ + command: "drag_drop", + DragNodeClass: DragAndDrop.DragNodeClass, + TabsIds: DragAndDrop.TabsIds, + TabsIdsParents: DragAndDrop.TabsIdsParents, + TabsIdsSelected: DragAndDrop.TabsIdsSelected, + ComesFromWindowId: CurrentWindowId, + Depth: DragAndDrop.Depth, + Folders: DragAndDrop.Folders, + FoldersSelected: DragAndDrop.FoldersSelected + }); + } + fh.ondragenter = function(event) { + this.classList.remove("folder_header_hover"); + } + fh.onmouseover = function(event) { + this.classList.add("folder_header_hover"); + if (opt.never_show_close == false && opt.always_show_close == false) { + this.classList.add("close_show"); + } + } + fh.onmouseleave = function(event) { + this.classList.remove("folder_header_hover"); + if (opt.never_show_close == false && opt.always_show_close == false) { + this.classList.remove("close_show"); + } + } + dc.ondragenter = function(event) { + // DRAGENTER PIN,TAB,FOLDER==>DROP ZONES + DragAndDrop.timeout = false; + setTimeout(function() { + DragAndDrop.timeout = true; + }, 1000); + if (DragAndDrop.DragNodeClass == "tab" || DragAndDrop.DragNodeClass == "folder") { + HighlightDragEnter(this, 0, "folder"); + } + } + du.ondragenter = function(event) { + // FOLDER==>FOLDER + if (DragAndDrop.DragNodeClass == "tab" || DragAndDrop.DragNodeClass == "folder") { + HighlightDragEnter(this, 1, "folder"); + } + } + dd.ondragenter = function(event) { + // FOLDER==>FOLDER + if (DragAndDrop.DragNodeClass == "tab" || DragAndDrop.DragNodeClass == "folder") { + HighlightDragEnter(this, 1, "folder"); + } + } + ex.onmousedown = function(event) { + if (document.getElementById("main_menu").style.top != "-1000px") { + HideMenus(); + } + // EXPAND/COLLAPSE FOLDER + if (event.which == 1 && !event.shiftKey && !event.ctrlKey) { + event.stopPropagation(); + EventExpandBox(this.parentNode.parentNode); + RefreshExpandStates(); + RefreshCounters(); + } + } + } + if (ParentId == "" || ParentId == undefined || document.getElementById("cf"+ParentId) == null) { + document.getElementById("cf"+active_group).appendChild(fd); } else { - $("#cf"+param.ParentId).append(fd); + document.getElementById("cf"+ParentId).appendChild(fd); } } } + function GenerateNewFolderID() { var newID = "f_"+GenerateRandomID(); - if ($("#"+newID)[0]) { - GenerateNewFolderID(); - } else { + if (document.getElementById(newID) == null) { return newID; + } else { + GenerateNewFolderID(); } } + function AppendFolders(Folders) { for (var folderId in Folders) { - AppendFolder({id: folderId, ParentId: Folders[folderId].parent, name: Folders[folderId].name, expand: Folders[folderId].expand}); + AppendFolder(folderId, Folders[folderId].name, Folders[folderId].parent, Folders[folderId].expand, true); } - // APPEND FOLDERS TO PARENTS for (var folderId in Folders) { - if ($("#"+folderId)[0] && Folders[folderId].parent != $("#"+folderId).parent().parent()[0].id) { - $("#cf"+Folders[folderId].parent).append($("#"+folderId)); + let f = document.getElementById(folderId); + let parent = document.getElementById("cf"+Folders[folderId].parent); + if (f != null && parent != null && Folders[folderId].parent != f.parentNode.parentNode.id) { + parent.appendChild(f); } } } + function SaveFolders() { - $(".folder").each(function() { - bgfolders[this.id].parent = $(this).parent().parent()[0].id; - bgfolders[this.id].index = $(this).index(); - bgfolders[this.id].expand = ($(this).is(".n") ? "n" : ($(this).is(".c") ? "c" : "o")); + document.querySelectorAll(".folder").forEach(function(s){ + bgfolders[s.id].parent = s.parentNode.parentNode.id; + bgfolders[s.id].index = Array.from(s.parentNode.children).indexOf(s); + bgfolders[s.id].expand = (s.classList.contains("c") ? "c" : (s.classList.contains("o") ? "o" : "")); }); chrome.runtime.sendMessage({command: "save_folders", folders: bgfolders, windowId: CurrentWindowId}); } + function RearrangeFolders(first_loop) { - $(".folder").each(function() { - if (bgfolders[this.id] && $(this).parent().children().eq(bgfolders[this.id].index)[0]) { - if ($(this).index() > bgfolders[this.id].index) { - $(this).insertBefore($(this).parent().children().eq(bgfolders[this.id].index)); + document.querySelectorAll(".folder").forEach(function(s){ + if (bgfolders[s.id] && s.parentNode.childNodes[bgfolders[s.id].index]) { + let Ind = Array.from(s.parentNode.children).indexOf(s); + if (Ind > bgfolders[s.id].index) { + s.parentNode.childNodes[bgfolders[s.id].index].parentNode.insertBefore(s, s.parentNode.childNodes[bgfolders[s.id].index]); } else { - $(this).insertAfter($(this).parent().children().eq(bgfolders[this.id].index)); + if (s.parentNode.childNodes[bgfolders[s.id].index].nextSibling != null) { + s.parentNode.childNodes[bgfolders[s.id].index].parentNode.insertBefore(s, s.parentNode.childNodes[bgfolders[s.id].index].nextSibling); + } else { + s.parentNode.childNodes[bgfolders[s.id].index].parentNode.appendChild(s); + } } } - if (bgfolders[this.id] && $(this).index() != bgfolders[this.id].index && first_loop) { + let newInd = Array.from(s.parentNode.children).indexOf(s); + if (bgfolders[s.id] && newInd != bgfolders[s.id].index && first_loop) { RearrangeFolders(false); } }); } + function RemoveFolder(FolderId) { - if ($("#"+FolderId)[0]) { + let folder = document.getElementById(FolderId); + if (folder != null) { + let CF = folder.childNodes[4]; // CF stands for DIV with children folders + let CT = folder.childNodes[5]; // CT stands for DIV with children tabs if (opt.promote_children == true) { - if (opt.promote_children_in_first_child == true && $("#cf"+FolderId).children().length > 0) { - let FirstChild = $("#cf"+FolderId).children()[0]; - $(FirstChild).insertAfter($("#"+FolderId)); - $("#cf"+FirstChild.id).append($("#cf"+FolderId).children()); - if ($("#ch"+FolderId).children().length > 0) { - $("#ch"+FirstChild.id).append($("#ch"+FolderId).children()); - } + if (opt.promote_children_in_first_child == true && CF.children.length > 0) { + let FirstFolderChild = CF.firstChild; + folder.parentNode.insertBefore(FirstFolderChild, folder); + let NewCF = FirstFolderChild.childNodes[4]; + while (CF.firstChild) { + NewCF.appendChild(CF.firstChild); + } + if (CT.childNodes.length > 0) { + let NewCT = FirstFolderChild.childNodes[5]; + while (CT.firstChild) { + NewCT.appendChild(CT.firstChild); + } + } } else { - $("#ch"+($("#"+FolderId).parent().parent()[0].id)).append($("#ch"+FolderId).children()); - $("#cf"+FolderId).children().insertAfter($("#"+FolderId)); + let NewCT = document.getElementById("ct"+folder.parentNode.parentNode.id); + // let NewCT = folder.parentNode.parentNode.childNodes[5]; + while (CT.firstChild) { + NewCT.appendChild(CT.firstChild); + } + while (CF.lastChild) { + folder.parentNode.insertBefore(CF.lastChild, folder); + } } } else { - $("#"+FolderId+" .tab").each(function() { - chrome.tabs.remove(parseInt(this.id), null); + document.querySelectorAll("#"+FolderId+" .tab").forEach(function(s){ + chrome.tabs.remove(parseInt(s.id), null); }); - $("#"+FolderId+" .folder").each(function() { - delete bgfolders[this.id]; + + document.querySelectorAll("#"+FolderId+" .folder").forEach(function(s){ + delete bgfolders[s.id]; }); } - $("#"+FolderId).remove(); + folder.parentNode.removeChild(folder); delete bgfolders[FolderId]; RefreshExpandStates(); chrome.runtime.sendMessage({command: "save_folders", folders: bgfolders, windowId: CurrentWindowId}); } } + function SetActiveFolder(FolderId) { - if ($("#"+FolderId).length > 0) { - $(".selected_folder").removeClass("selected_folder"); - $("#"+FolderId).addClass("selected_folder"); + let folder = document.getElementById(FolderId); + if (folder != null) { + document.querySelectorAll(".selected_folder").forEach(function(s){ + s.classList.remove("selected_folder"); + }); + folder.classList.add("selected_folder"); } } -// Rename folder popup -function ShowRenameFolderDialog(FolderId) { - $("#folder_edit_name")[0].value = bgfolders[FolderId].name; - $("#folder_edit_name").data("FolderId", FolderId); - $("#folder_edit").css({"display": "block", "top": $("#toolbar_groups").offset().top + 8, "left": 22}); + +function ShowRenameFolderDialog(FolderId) { // Rename folder popup + HideRenameDialogs(); + if (bgfolders[FolderId]) { + let name = document.getElementById("folder_edit_name"); + name.value = bgfolders[FolderId].name; + let folderEditDialog = document.getElementById("folder_edit"); + folderEditDialog.setAttribute("FolderId", FolderId); + folderEditDialog.style.display = "block"; + folderEditDialog.style.top = document.getElementById("toolbar").getBoundingClientRect().height + document.getElementById("pin_list").getBoundingClientRect().height + 8 + "px"; + folderEditDialog.style.left = "22px"; + setTimeout(function(){ + document.getElementById("folder_edit_name").select(); + },5); + } } -// when pressed OK in folder popup -function FolderRenameConfirm() { - $("#folder_edit_name")[0].value = $("#folder_edit_name")[0].value.replace(/[\f\n\r\v\t\<\>\+\-\(\)\.\,\;\:\~\/\|\?\@\!\"\'\£\$\%\&\^\#\=\*\[\]]?/gi, ""); - bgfolders[$("#folder_edit_name").data("FolderId")].name = $("#folder_edit_name")[0].value; - $("#folder_title"+$("#folder_edit_name").data("FolderId"))[0].innerText = $("#folder_edit_name")[0].value; - $(".edit_dialog").hide(0); + +function FolderRenameConfirm() { // when pressed OK in folder popup + let name = document.getElementById("folder_edit_name"); + let FolderId = document.getElementById("folder_edit").getAttribute("FolderId"); + name.value = name.value.replace(/[\f\n\r\v\t\<\>\+\-\(\)\.\,\;\:\~\/\|\?\@\!\"\'\£\$\%\&\^\#\=\*\[\]]?/gi, ""); + bgfolders[FolderId].name = name.value; + document.getElementById("folder_title" + FolderId).textContent = name.value; + HideRenameDialogs(); chrome.runtime.sendMessage({command: "save_folders", folders: bgfolders, windowId: CurrentWindowId}); RefreshCounters(); } -function SetFolderEvents() { - // EXPAND BOX - EXPAND / COLLAPSE - $(document).on("click", ".folder_icon", function(event) { - event.stopPropagation(); - if (event.button == 0) { - if ($(this).parent().parent().is(".o")) { - $(this).parent().parent().removeClass("o").addClass("c"); - } else { - if ($(this).parent().parent().is(".c")) { - $(this).parent().parent().removeClass("c").addClass("o"); - } - } - RefreshExpandStates(); - RefreshCounters(); - SaveFolders(); - } + +function DeselectFolders() { + document.querySelectorAll("#"+active_group+" .selected_folder").forEach(function(s){ + s.classList.remove("selected_folder"); }); - // SINGLE CLICK TO ACTIVATE FOLDER - $(document).on("click", ".folder_header", function(event) { - event.stopPropagation(); - if (event.button == 0 && !event.shiftKey) { - $("#"+active_group+" .tab").removeClass("selected_tab"); - if (!event.ctrlKey) { - $(".selected_folder:not(#"+($(this).parent()[0].id)+")").removeClass("selected_folder"); - } - // SetActiveFolder(); - $(this).parent().toggleClass("selected_folder"); - } - }); - // CLOSE TAB/PIN - $(document).on("mousedown", ".folder_header", function(event) { - if ((event.button == 1 && opt.close_with_MMB == true) || (event.button == 0 && $(event.target).is(".close, .close_img"))) { - RemoveFolder($(this).parent()[0].id); - } - if (event.button == 2) { - event.stopPropagation(); - ShowFolderMenu($(this).parent(), event); - } - }); - // edit folder dialog box - $(document).on("mousedown", "#folder_edit_discard", function(event) { - $(".edit_dialog").hide(0); - }); - $("#folder_edit_name").keyup(function(e) { - if (e.keyCode == 13) { - FolderRenameConfirm(); - } - }); - $(document).on("mousedown", "#folder_edit_confirm", function(event) { - FolderRenameConfirm(); - }); - // edit folder - $(document).on("dblclick", ".folder_title", function(event) { - if (event.button == 0) { - ShowRenameFolderDialog($(this).parent().parent()[0].id); - } - }); - $(document).on("mouseover", ".folder_header", function(event) { - $(this).addClass("folder_header_hover"); - if (opt.always_show_close == false) { - $(this).addClass("close_show"); - } - }); - $(document).on("mouseleave", ".folder_header", function(event) { - $(this).removeClass("folder_header_hover"); - if (opt.always_show_close == false) { - $(this).removeClass("close_show"); - } - }); -} \ No newline at end of file +} + +function ActionClickFolder(FolderNode, bgOption) { + if (bgOption == "rename_folder") { + ShowRenameFolderDialog(FolderNode.id); + } + if (bgOption == "new_folder") { + AddNewFolder(FolderNode.id, undefined, undefined, undefined); + } + if (bgOption == "new_tab") { + OpenNewTab(false, FolderNode.id); + } + if (bgOption == "expand_collapse") { + EventExpandBox(FolderNode); + } + if (bgOption == "close_folder") { + RemoveFolder(FolderNode.id); + } + if (bgOption == "unload_folder") { + let tabsArr = []; + document.querySelectorAll("#"+FolderNode.id+" .tab").forEach(function(s){ + tabsArr.push(parseInt(s.id)); + }); + DiscardTabs(tabsArr); + } +} + diff --git a/scripts/global.js b/scripts/global.js index 33c0fc0..4876e51 100644 --- a/scripts/global.js +++ b/scripts/global.js @@ -11,25 +11,24 @@ var schedule_rearrange_tabs = 0; var schedule_rearrange_reverse = false; var windows = {}; var tabs = {}; -var MouseHoverOver = ""; +var tt_ids = {}; var DragAndDrop = { timeout: false, - DragNode: undefined, + Depth: 0, + // DragNode: undefined, DragNodeClass: "", TabsIds: [], TabsIdsParents: [], TabsIdsSelected: [], Folders: {}, FoldersSelected: [], - ComesFromWindowId: 0, - DroppedToWindowId: 0, - Depth: 0 + ComesFromWindowId: undefined, + DroppedToWindowId: 0 }; -var menuItemId = 0; +var menuItemNode; var CurrentWindowId = 0; var SearchIndex = 0; var active_group = "tab_list"; -var PickColor = ""; var opt = {}; var browserId = navigator.userAgent.match("Opera") !== null ? "O" : ( navigator.userAgent.match("Vivaldi") !== null ? "V" : (navigator.userAgent.match("Firefox") !== null ? "F" : "C" ) ); var bgtabs = {}; @@ -40,7 +39,7 @@ var caption_loading = chrome.i18n.getMessage("caption_loading"); var caption_searchbox = chrome.i18n.getMessage("caption_searchbox"); var caption_ungrouped_group = chrome.i18n.getMessage("caption_ungrouped_group"); var caption_noname_group = chrome.i18n.getMessage("caption_noname_group"); -var DefaultToolbar = +const DefaultToolbar = '
'+ '
'+ '
'+ @@ -71,8 +70,8 @@ var DefaultToolbar = '
'+ '
' : '')+ - '
'+ - '
'+ + '
'+ + '
'+ '
'+ '
'+ '
'+ @@ -101,28 +100,30 @@ var DefaultTheme = { "ToolbarShow": true, "ColorsSet": {}, "TabsSizeSetNumber": 2, + "TabsMargins": "2", "theme_name": "untitled", - "theme_version": 2, + "theme_version": 3, "toolbar": DefaultToolbar, "unused_buttons": "" }; var DefaultPreferences = { "skip_load": false, - "pin_list_multi_row": false, - "close_with_MMB": true, + "pin_list_multi_row": true, "always_show_close": false, + "never_show_close": false, "allow_pin_close": false, "append_child_tab": "bottom", "append_child_tab_after_limit": "after", "append_orphan_tab": "bottom", "after_closing_active_tab": "below_seek_in_parent", - "close_other_trees": false, + "collapse_other_trees": false, + "open_tree_on_hover": true, "promote_children": true, "promote_children_in_first_child": true, - "open_tree_on_hover": true, "max_tree_depth": -1, + // "max_tree_depth_folders": 0, "max_tree_drag_drop": true, - "never_show_close": false, + "max_tree_drag_drop_folders": false, "switch_with_scroll": false, "syncro_tabbar_tabs_order": true, "show_counter_groups": true, @@ -130,10 +131,17 @@ var DefaultPreferences = { "show_counter_tabs_hints": true, "groups_toolbar_default": true, "syncro_tabbar_groups_tabs_order": true, + "midclick_tab": "close_tab", + "dbclick_tab": "new_tab", + "dbclick_group": "new_tab", + "midclick_group": "nothing", + "midclick_folder": "nothing", + "dbclick_folder": "rename_folder", "debug": false }; var theme = { "TabsSizeSetNumber": 2, + "TabsMargins": "2", "ToolbarShow": true, "toolbar": DefaultToolbar }; @@ -159,35 +167,69 @@ function HexToRGB(hex, alpha){ if (alpha) { return 'rgba('+r+', '+g+', '+b+', '+alpha+')'; } else { return 'rgb('+r+', '+g+', '+b+')'; } } - function GetCurrentTheme() { chrome.storage.local.get(null, function(items) { if (items["current_theme"] && items["themes"] && items["themes"][items["current_theme"]]) { theme = items["themes"][items["current_theme"]]; + if (theme.theme_version == 1) { + theme["ColorsSet"]["scrollbar_height"] = theme.ScrollbarPinList + "px"; + theme["ColorsSet"]["scrollbar_width"] = theme.ScrollbarTabList + "px"; + theme["toolbar"] = DefaultToolbar; + theme["unused_buttons"] = ""; + } + if (theme.theme_version == 2) { + SelectedTheme["TabsMargins"] = "2"; + } } else { theme = Object.assign({}, DefaultTheme); } }); } + function ApplyTheme(theme) { + if (theme.theme_version == 1) { + theme["ColorsSet"]["scrollbar_height"] = theme.ScrollbarPinList + "px"; + theme["ColorsSet"]["scrollbar_width"] = theme.ScrollbarTabList + "px"; + theme["toolbar"] = DefaultToolbar; + theme["unused_buttons"] = ""; + } + if (theme.theme_version == 2) { + theme["TabsMargins"] = "2"; + } RestoreStateOfGroupsToolbar(); ApplySizeSet(theme["TabsSizeSetNumber"]); ApplyColorsSet(theme["ColorsSet"]); - if (theme.ToolbarShow) { + ApplyTabsMargins(theme["TabsMargins"]); + if (theme.ToolbarShow == true) { + SetToolbarEvents(true, false, false, ""); if (theme.theme_version == DefaultTheme.theme_version) { - $("#toolbar").html(theme.toolbar); + document.getElementById("toolbar").innerHTML = theme.toolbar; if (browserId == "F") { - $(".button#button_load_bak1, .button#button_load_bak2, .button#button_load_bak3").remove(); + document.querySelectorAll(".button#button_load_bak1, .button#button_load_bak2, .button#button_load_bak3").forEach(function(s){ + s.parentNode.removeChild(s); + }); } } else { - $("#toolbar").html(DefaultToolbar); + document.getElementById("toolbar").innerHTML = DefaultToolbar; } - } - RestoreToolbarShelf(); - RestoreToolbarSearchFilter(); + SetToolbarEvents(false, true, true, "mousedown"); + RestoreToolbarShelf(); + RestoreToolbarSearchFilter(); + } else { + document.getElementById("toolbar").innerHTML = ""; + RefreshGUI(); + } + + for (var groupId in bggroups) { + let groupTitle = document.getElementById("_gte"+groupId); + if (groupTitle != null && bggroups[groupId].font == "") { + groupTitle.style.color = ""; + } + } Loadi18n(); } -/* theme colors is an object with css variables (but without --), for example; {"button_background": "#f2f2f2", "filter_box_border": "#cccccc"} */ + +// theme colors is an object with css variables (but without --), for example; {"button_background": "#f2f2f2", "filter_box_border": "#cccccc"} function ApplyColorsSet(ThemeColors){ let css_variables = ""; for (let css_variable in ThemeColors) { @@ -221,21 +263,22 @@ function ApplySizeSet(size){ } } -function LoadPreferences() { - opt = Object.assign({}, DefaultPreferences); - chrome.storage.local.get(null, function(items) { - if (items["preferences"]) { - for (var parameter in items["preferences"]) { - if (opt[parameter] != undefined) { - opt[parameter] = items["preferences"][parameter]; - } +function ApplyTabsMargins(size){ + for (let si = 0; si < document.styleSheets.length; si++) { + if ((document.styleSheets[si].ownerNode.id).match("tabs_margin") != null) { + if (document.styleSheets[si].ownerNode.id == "tabs_margin_"+size) { + document.styleSheets.item(si).disabled = false; + } else { + document.styleSheets.item(si).disabled = true; } } - }); + } } + function LoadDefaultPreferences() { opt = Object.assign({}, DefaultPreferences); } + function SavePreferences() { chrome.runtime.sendMessage({command: "save_preferences", opt: opt}, function(response) { setTimeout(function() { @@ -243,6 +286,7 @@ function SavePreferences() { }, 300); }); } + function ShowOpenFileDialog(id, extension) { let body = document.getElementById("body"); let inp = document.createElement("input"); @@ -251,23 +295,43 @@ function ShowOpenFileDialog(id, extension) { inp.accept = extension; inp.style.display = "none"; body.appendChild(inp); - $("#"+id).click(); -} -function SaveFile(filename, data) { - let d = JSON.stringify(data); - let body = document.getElementById("body"); - let link = document.createElement("a"); - link.target = "_self"; - link.download = filename; - link.href = "data:text/csv;charset=utf-8," + encodeURIComponent(d); - body.appendChild(link); - link.click(); - link.remove(); + inp.click(); + return inp; } -function log(m) { - if (opt.debug) { - console.log(m); - } - // chrome.runtime.sendMessage({command: "console_log", m: m}); +function SaveFile(filename, data) { + chrome.tabs.query({currentWindow: true, active: true}, function(activeTab) { + chrome.tabs.create({url: "download.html"}, function(tab) { + setTimeout(function() { + chrome.runtime.sendMessage({command: "show_save_file_dialog", currentTabId: activeTab[0].id, selfTabId: tab.id, data: data, filename: filename}); + }, 100); + }); + }); +} + +// function SaveFile(filename, data) { + // let file = new File([JSON.stringify(data)], filename, {type: "text/csv;charset=utf-8"} ); + // let body = document.getElementById("body"); + // let savelink = document.createElement("a"); + // savelink.target = "_blank"; + // savelink.style.display = "none"; + // savelink.type = "file"; + // savelink.download = filename; + // savelink.href = URL.createObjectURL(file); + // body.appendChild(savelink); + // savelink.click(); + // savelink.parentNode.removeChild(savelink); +// } + +function EmptyDragAndDrop() { + DragAndDrop.timeout = false; + DragAndDrop.DragNodeClass = ""; + DragAndDrop.DroppedToWindowId = 0; + DragAndDrop.ComesFromWindowId = undefined; + DragAndDrop.Depth = 0; + DragAndDrop.TabsIds = []; + DragAndDrop.TabsIdsParents = []; + DragAndDrop.TabsIdsSelected = []; + DragAndDrop.Folders = {}; + DragAndDrop.FoldersSelected = []; } \ No newline at end of file diff --git a/scripts/groups.js b/scripts/groups.js index a54858b..ba26f21 100644 --- a/scripts/groups.js +++ b/scripts/groups.js @@ -7,151 +7,291 @@ function SaveGroups() { chrome.runtime.sendMessage({command: "save_groups", groups: bggroups, windowId: CurrentWindowId}); } + function AppendGroups(Groups) { - // var scroll = $("#group_list").scrollTop(); + // let GroupList = document.getElementById("group_list"); + // let scroll = GroupList.scrollTop; + + AppendGroupToList("tab_list", caption_ungrouped_group, "", true); + for (var group in Groups) { - AppendGroupToList(Groups[group].id, Groups[group].name, Groups[group].font); + AppendGroupToList(Groups[group].id, Groups[group].name, Groups[group].font, true); + if (document.querySelectorAll(".group").length == Object.keys(Groups).length) { + RearrangeGroupsButtons(); + setTimeout(function() { + RearrangeGroupsLists(); + }, 50); + } } - setTimeout(function() { - RearrangeGroupsButtons(0); - }, 1000); } -function RearrangeGroupsButtons(stack) { - $(".group_button").each(function() { - let groupId = (this.id).substr(1); +function RearrangeGroupsButtons(first_loop) { + document.querySelectorAll(".group_button").forEach(function(s){ + let groupId = (s.id).substr(1); if (bggroups[groupId]) { - if ($("#group_list").children().eq(bggroups[groupId].index)[0] && $(this).index() > bggroups[groupId].index) { - $(this).insertBefore($("#group_list").children().eq(bggroups[groupId].index)[0]); - } else { - if ($("#group_list").children().eq(bggroups[groupId].index)[0] && $(this).index() < bggroups[groupId].index) { - $(this).insertAfter($("#group_list").children().eq(bggroups[groupId].index)[0]); + if (s.parentNode.childNodes[bggroups[groupId].index] != undefined) { + let Ind = Array.from(s.parentNode.children).indexOf(s); + if (Ind > bggroups[groupId].index) { + s.parentNode.childNodes[bggroups[groupId].index].parentNode.insertBefore(s, s.parentNode.childNodes[bggroups[groupId].index]); + } else { + if (s.parentNode.childNodes[bggroups[groupId].index].nextSibling != null) { + s.parentNode.childNodes[bggroups[groupId].index].parentNode.insertBefore(s, s.parentNode.childNodes[bggroups[groupId].index].nextSibling); + } else { + s.parentNode.childNodes[bggroups[groupId].index].parentNode.appendChild(s); + } + } + let newInd = Array.from(s.parentNode.children).indexOf(s); + if (newInd != bggroups[groupId].index && first_loop) { + RearrangeGroupsButtons(false); } } - if ($(this).index() != bggroups[groupId].index && stack < 10) { - RearrangeGroupsButtons(stack+1); - } } }); } -function RearrangeGroupsLists() { - let scroll = $("#"+active_group).scrollTop(); - $(".group_button").each(function() { - let groupId = (this.id).substr(1); - if ($("#"+groupId)[0]) { - $("#groups").append($("#"+groupId)); - } - }); - $("#"+active_group).scrollTop(scroll); -} -function AppendGroupToList(groupId, group_name, font_color) { - if ($("#"+groupId).length == 0 && $("#groups")[0]) { - var grp = document.createElement("div"); grp.className = "group"; grp.id = groupId; $("#groups")[0].appendChild(grp); - var gcf = document.createElement("div"); gcf.className = "children_folders"; gcf.id = "cf"+groupId; grp.appendChild(gcf); - var gct = document.createElement("div"); gct.className = "children_tabs"; gct.id = "ch"+groupId; grp.appendChild(gct); +function RearrangeGroupsLists() { + let activegroup = document.getElementById(active_group); + let scroll = activegroup.scrollTop; + let groups = document.getElementById("groups"); + document.querySelectorAll(".group_button").forEach(function(s){ + let group = document.getElementById((s.id).substr(1)); + if (group != null) { + groups.appendChild(group); + } + }); + activegroup.scrollTop = scroll; +} + +function AppendGroupToList(groupId, group_name, font_color, SetEvents) { + if (document.getElementById(groupId) == null) { + let grp = document.createElement("div"); grp.className = "group"; grp.id = groupId; grp.style.display = "none"; document.getElementById("groups").appendChild(grp); + let gcf = document.createElement("div"); gcf.className = "children_folders"; gcf.id = "cf"+groupId; grp.appendChild(gcf); + let gct = document.createElement("div"); gct.className = "children_tabs"; gct.id = "ct"+groupId; grp.appendChild(gct); + if (SetEvents) { + grp.onmousedown = function(event) { + event.stopImmediatePropagation(); + if (event.which == 1 && event.target == this) { + DeselectFolders(); + DeselectTabs(); + HideMenus(); + } + if (event.which == 2) { + event.preventDefault(); + ActionClickGroup(this, opt.midclick_group); + } + if (event.which == 3 && event.target.id == this.id) { + // SHOW MENU + ShowFGlobalMenu(event); + } + } + grp.ondragenter = function(event) { + // PIN,TAB==>GROUP + if (event.target.id == this.id && (DragAndDrop.DragNodeClass == "tab" || DragAndDrop.DragNodeClass == "folder")) { + HighlightNode(this); + } + } + // DOUBLE CLICK ACTION + grp.ondblclick = function(event) { + if (event.target.id == this.id) { + ActionClickGroup(this, opt.dbclick_group); + } + } + + if (opt.switch_with_scroll) { + BindTabsSwitchingToMouseWheel(groupId); + } + + } + } - if ($("#_"+groupId).length == 0) { - var gbn = document.createElement("div"); gbn.className = "group_button"; gbn.id = "_"+groupId; $("#group_list")[0].appendChild(gbn); - var gte = document.createElement("span"); gte.className = "group_title"; gte.id = "_gte"+groupId; gte.textContent = group_name; if (font_color != "") {gte.style.color = "#"+font_color;} gbn.appendChild(gte); - var gtd = document.createElement("div"); gtd.className = "group_drag_box"; gtd.draggable = true; gtd.id = "-"+groupId; gbn.appendChild(gtd); - } - if (groupId != active_group) { - $("#"+groupId).hide(); + + if (document.getElementById("_"+groupId) == null) { + let gbn = document.createElement("div"); gbn.className = "group_button"; gbn.id = "_"+groupId; document.getElementById("group_list").appendChild(gbn); + let gte = document.createElement("span"); gte.className = "group_title"; gte.id = "_gte"+groupId; gte.textContent = group_name; + if (font_color != "") { + gte.style.color = "#"+font_color; + } else { + gte.style.color = window.getComputedStyle(document.getElementById("body"), null).getPropertyValue("--group_list_default_font_color"); + } + gbn.appendChild(gte); + let gtd = document.createElement("div"); gtd.className = "drop_target group_drag_box"; if (SetEvents) {gtd.draggable = true;} gtd.id = "-"+groupId; gbn.appendChild(gtd); + let gdd = document.createElement("div"); gdd.className = "drop_target group_button_drag_entered_bottom"; gdd.id = "dd"+groupId; gbn.appendChild(gdd); + let gdu = document.createElement("div"); gdu.className = "drop_target group_button_drag_entered_top"; gdu.id = "du"+groupId; gbn.appendChild(gdu); + + if (SetEvents) { + + // ACTIVATE GROUP + gtd.onclick = function(event) { + SetActiveGroup(this.id.substr(1), true, true); + } + + // SHOW GROUP MENU + gbn.onmousedown = function(event) { + // event.stopImmediatePropagation(); + if (event.which == 3) { + ShowFGroupMenu(document.getElementById(this.id.substr(1)), event); + } + } + + // EDIT GROUP + gtd.ondblclick = function(event) { + if (event.which == 1 && this.id != "-tab_list") { + ShowGroupEditWindow((this.id).substr(1)); + } + } + + // DRAGGING GROUPS + gtd.ondragstart = function(event) { // DRAG START + event.stopPropagation(); + event.dataTransfer.setDragImage(document.getElementById("DragImage"), 0, 0); + event.dataTransfer.setData("text", ""); + // event.dataTransfer.setData("text/plain", ""); + // event.dataTransfer.setData("TTSourceWindowId", CurrentWindowId); + CleanUpDragClasses(); + EmptyDragAndDrop(); + + DragAndDrop.ComesFromWindowId = CurrentWindowId; + DragAndDrop.DragNodeClass = "group"; + // DragAndDrop.DragNode = event.target.parentNode; + + this.parentNode.classList.add("dragged_group_button"); + // event.dataTransfer.setData("null", "null"); + DropTargetsFront(this, false, true); + } + + gtd.ondragenter = function(event) { // DRAG START + if (DragAndDrop.DragNodeClass == "tab" || DragAndDrop.DragNodeClass == "folder") { + HighlightNode(this); + } + } + + gdu.ondragenter = function(event) { // DRAG START + if (DragAndDrop.DragNodeClass == "group") { + HighlightNode(this); + } + } + + gdd.ondragenter = function(event) { // DRAG START + // GROUP BUTTON==>GROUP BUTTON + if (DragAndDrop.DragNodeClass == "group") { + HighlightNode(this); + } + } + // scroll groups + // $(document).on("mousedown", "#scroll_group_up, #scroll_group_down", function(event) { + // IOKeys.LMB = true; + // ScrollGroupList($(this).is("#scroll_group_up")); + // }); + // $(document).on("mouseleave", "#scroll_group_up, #scroll_group_down", function(event) { + // IOKeys.LMB = false; + // }); + } } RefreshGUI(); - - if (opt.switch_with_scroll) { - BindTabsSwitchingToMouseWheel(); - } } function GenerateNewGroupID(){ - var newID = "g_"+GenerateRandomID(); - if ($("#"+newID)[0]) { - GenerateNewGroupID(); - } else { + let newID = "g_"+GenerateRandomID(); + if (document.getElementById(newID) == null) { return newID; + } else { + GenerateNewGroupID(); } } -function AddNewGroup(p) { - var newId = GenerateNewGroupID(); - bggroups[newId] = { id: newId, index: 0, active_tab: 0, active_tab_ttid: "", name: (p.name ? p.name : caption_noname_group), font: (p.font ? p.font : "") }; - AppendGroupToList(newId, bggroups[newId].name, bggroups[newId].font); +function AddNewGroup(Name, FontColor) { + let newId = GenerateNewGroupID(); + bggroups[newId] = { id: newId, index: 0, active_tab: 0, prev_active_tab: 0, active_tab_ttid: "", name: (Name ? Name : caption_noname_group), font: (FontColor ? FontColor : "") }; + AppendGroupToList(newId, bggroups[newId].name, bggroups[newId].font, true); UpdateBgGroupsOrder(); return newId; } -// function AppendTabsToGroup(p) { -// } - // remove group, delete tabs if close_tabs is true function GroupRemove(groupId, close_tabs) { if (close_tabs) { - CloseTabs($("#"+groupId).find(".tab").map(function() {return parseInt(this.id);}).toArray()); - $("#"+groupId+" .folder").each(function() { - RemoveFolder(this.id); + let tabIds = Array.prototype.map.call(document.querySelectorAll("#"+groupId+" .tab"), function(s){ + return parseInt(s.id); + }); + CloseTabs(tabIds); + document.querySelectorAll("#"+groupId+" .folder").forEach(function(s){ + RemoveFolder(s.id); }); } else { - $("#cf"+groupId).children().each(function() { - $("#cftab_list").append(this); - }); - $("#ch"+groupId).children().each(function() { - $("#chtab_list").append(this); - }); + let TabListFolders = document.getElementById("cftab_list"); + let GroupFolders = document.getElementById("cf"+groupId); + while (GroupFolders.firstChild) { + TabListFolders.appendChild(GroupFolders.firstChild); + } + let TabListTabs = document.getElementById("cttab_list"); + let GroupTabs = document.getElementById("ct"+groupId); + while (GroupTabs.firstChild) { + TabListTabs.appendChild(GroupTabs.firstChild); + } RefreshExpandStates(); RefreshCounters(); } delete bggroups[groupId]; - - if ($("#"+groupId)[0].id == active_group) { - if ($("#_"+groupId).prev(".group_button")[0]) { - SetActiveGroup(($("#_"+groupId).prev(".group_button")[0].id).substr(1), true, true); + if (groupId == active_group) { + if (document.getElementById("_"+groupId).previousSibling) { + SetActiveGroup((document.getElementById("_"+groupId).previousSibling.id).substr(1), true, true); } else { - if ($("#_"+groupId).next(".group_button")[0]) { - SetActiveGroup(($("#_"+groupId).next(".group_button")[0].id).substr(1), true, true); + if (document.getElementById("_"+groupId).nextSibling) { + SetActiveGroup((document.getElementById("_"+groupId).nextSibling.id).substr(1), true, true); } else { SetActiveGroup("tab_list", true, true); } } } SaveGroups(); - $("#"+groupId).remove(); - $("#_"+groupId).remove(); + let group = document.getElementById(groupId); + group.parentNode.removeChild(group); + let groupButton = document.getElementById("_"+groupId); + groupButton.parentNode.removeChild(groupButton); schedule_update_data++; } function UpdateBgGroupsOrder() { - $(".group_button").each(function() { - if (bggroups[(this.id).substr(1)]) { - bggroups[(this.id).substr(1)].index = $(this).index(); + document.querySelectorAll(".group_button").forEach(function(s){ + if (bggroups[(s.id).substr(1)]) { + bggroups[(s.id).substr(1)].index = Array.from(s.parentNode.children).indexOf(s); } }); SaveGroups(); } function SetActiveGroup(groupId, switch_to_active_in_group, scroll_to_active) { - log("function: SetActiveGroup"); - if ($("#"+groupId)[0]) { + if (opt.debug) console.log("function: SetActiveGroup"); + let group = document.getElementById(groupId); + if (group != null) { active_group = groupId; - $(".group_button").removeClass("active_group"); - $("#_"+groupId).addClass("active_group"); - $(".tab, .group").hide(); - $("#"+groupId).show(); - $("#"+groupId+" .tab").show(); + document.querySelectorAll(".group_button").forEach(function(s){ + s.classList.remove("active_group"); + }); + document.getElementById("_"+groupId).classList.add("active_group"); + document.querySelectorAll(".group").forEach(function(s){ + s.style.display = "none"; + }); + group.style.display = ""; RefreshGUI(); - $("#group_edit").hide(); - if (switch_to_active_in_group && $("#"+groupId+" .active_tab")[0]){ - chrome.tabs.update(parseInt($("#"+groupId+" .active_tab")[0].id), {active: true}); - } - if (scroll_to_active && $("#"+groupId+" .active_tab")[0]){ - ScrollToTab($("#"+groupId+" .active_tab")[0].id); + HideRenameDialogs() + let activeTab = document.querySelector("#"+groupId+" .active_tab"); + if (activeTab != null ){ + if (switch_to_active_in_group){ + chrome.tabs.update(parseInt(activeTab.id), {active: true}); + } + if (scroll_to_active){ + ScrollToTab(activeTab.id); + } } if (groupId == "tab_list") { - $("#button_remove_group, #button_edit_group").addClass("disabled"); + document.querySelectorAll("#button_remove_group, #button_edit_group").forEach(function(s){ + s.classList.add("disabled"); + }); } else { - $("#button_remove_group, #button_edit_group").removeClass("disabled"); + document.querySelectorAll("#button_remove_group, #button_edit_group").forEach(function(s){ + s.classList.remove("disabled"); + }); } chrome.runtime.sendMessage({command: "set_active_group", active_group: groupId, windowId: CurrentWindowId}); RefreshExpandStates(); @@ -160,20 +300,109 @@ function SetActiveGroup(groupId, switch_to_active_in_group, scroll_to_active) { } function SetActiveTabInGroup(groupId, tabId) { - if ($(".tab#"+tabId)[0] /* && $("#"+tabId).parents(".group")[0] */ && bggroups[groupId] != undefined) { - // bggroups[$("#"+tabId).parents(".group")[0].id].active_tab = parseInt(tabId); - // if ($("#"+tabId).parents(".group")[0].id != active_group) { + if (document.querySelector("#"+groupId+" [id='"+tabId+"']") != null && bggroups[groupId] != undefined) { if (groupId != active_group) { - // SetActiveGroup($("#"+tabId).parents(".group")[0].id, false, true); SetActiveGroup(groupId, false, true); } if (bggroups[groupId]) { + bggroups[groupId].prev_active_tab = bggroups[groupId].active_tab; bggroups[groupId].active_tab = parseInt(tabId); } SaveGroups(); } } +// Edit group popup +function ShowGroupEditWindow(groupId) { + HideRenameDialogs(); + if (bggroups[groupId]) { + let name = document.getElementById("group_edit_name"); + name.value = bggroups[groupId].name; + let groupEditDialog = document.getElementById("group_edit"); + groupEditDialog.setAttribute("groupId", groupId); + groupEditDialog.style.display = "block"; + groupEditDialog.style.top = document.getElementById("toolbar").getBoundingClientRect().height + document.getElementById("pin_list").getBoundingClientRect().height + 8 + "px"; + groupEditDialog.style.left = "22px"; + let DefaultGroupButtonFontColor = window.getComputedStyle(document.getElementById("body"), null).getPropertyValue("--group_list_default_font_color"); + let GroupEditFont = document.getElementById("group_edit_font"); + GroupEditFont.style.backgroundColor = (bggroups[groupId].font == "" ? DefaultGroupButtonFontColor : "#"+bggroups[groupId].font); + setTimeout(function(){ + document.getElementById("group_edit_name").select(); + },5); + } +} + +// when pressed OK in group popup +function GroupEditConfirm() { + let groupId = document.getElementById("group_edit").getAttribute("groupId"); + if (bggroups[groupId]) { + let GroupEditName = document.getElementById("group_edit_name"); + GroupEditName.value = GroupEditName.value.replace(/[\f\n\r\v\t\<\>\+\-\(\)\.\,\;\:\~\/\|\?\@\!\"\'\£\$\%\&\^\#\=\*\[\]]?/gi, ""); + bggroups[groupId].name = GroupEditName.value; + let GroupEditFont = document.getElementById("group_edit_font"); + let DefaultGroupButtonFontColor = window.getComputedStyle(document.getElementById("body"), null).getPropertyValue("--group_list_default_font_color"); + let ThisGroupButtonFontColor = RGBtoHex(GroupEditFont.style.backgroundColor); + if ("#"+ThisGroupButtonFontColor != DefaultGroupButtonFontColor) { + bggroups[groupId].font = ThisGroupButtonFontColor; + document.getElementById("_gte"+groupId).style.color = "#"+ThisGroupButtonFontColor; + } + HideRenameDialogs(); + RefreshGUI(); + SaveGroups(); + } +} + +function RestoreStateOfGroupsToolbar() { + chrome.runtime.sendMessage({command: "get_group_bar", windowId: CurrentWindowId}, function(response) { + let toolbarGroups = document.getElementById("toolbar_groups"); + if (response == true) { + toolbarGroups.style.display = "inline-block"; + toolbarGroups.style.width = "19px"; + toolbarGroups.style.borderRight = "1px solid var(--group_list_borders)"; + toolbarGroups.classList.remove("hidden"); + } else { + toolbarGroups.style.display = "none"; + toolbarGroups.style.width = "0px"; + toolbarGroups.style.borderRight = "none"; + toolbarGroups.classList.add("hidden"); + } + }); +} + +function GroupsToolbarToggle() { + let toolbarGroups = document.getElementById("toolbar_groups"); + toolbarGroups.classList.toggle("hidden"); + if (toolbarGroups.classList.contains("hidden")) { + toolbarGroups.style.display = "none"; + toolbarGroups.style.width = "0px"; + toolbarGroups.style.borderRight = "none"; + chrome.runtime.sendMessage({command: "set_group_bar", group_bar: false, windowId: CurrentWindowId}); + } else { + toolbarGroups.style.display = "inline-block"; + toolbarGroups.style.width = "19px"; + toolbarGroups.style.borderRight = "1px solid var(--group_list_borders)"; + chrome.runtime.sendMessage({command: "set_group_bar", group_bar: true, windowId: CurrentWindowId}); + } + RefreshGUI(); +} + +function ActionClickGroup(Node, bgOption) { + console.log(Node.id) + if (bgOption == "new_tab") { + if (Node.id == "pin_list") { + OpenNewTab(true, undefined); + } + if (Node.classList.contains("tab") || Node.classList.contains("folder") || Node.classList.contains("group")) { + OpenNewTab(false, Node.id); + } + } + if (bgOption == "activate_previous_active") { + chrome.tabs.update(parseInt(bggroups[active_group].prev_active_tab), {active: true}); + } +} +// function AppendTabsToGroup(p) { +// } + // direction == true goes up, false goes down // function ScrollGroupList(direction) { // if (direction) { @@ -197,28 +426,6 @@ function SetActiveTabInGroup(groupId, tabId) { // } // } -// Edit group popup -function ShowGroupEditWindow() { - if (bggroups[menuItemId]) { - $("#group_edit_name")[0].value = bggroups[menuItemId].name; - $("#group_edit").css({"display": "block", "top": $("#toolbar_groups").offset().top + 8, "left": 22}); - $("#group_edit_font").css({"background-color": bggroups[menuItemId].font == "" ? "var(--button_icons, #808080)" : "#"+bggroups[menuItemId].font}); - } -} - -// when pressed OK in group popup -function GroupEditConfirm() { - if (bggroups[menuItemId]) { - $("#group_edit_name")[0].value = $("#group_edit_name")[0].value.replace(/[\f\n\r\v\t\<\>\+\-\(\)\.\,\;\:\~\/\|\?\@\!\"\'\£\$\%\&\^\#\=\*\[\]]?/gi, ""); - bggroups[menuItemId].name = $("#group_edit_name")[0].value; - bggroups[menuItemId].font = RGBtoHex($("#group_edit_font").css("background-color")); - $(".edit_dialog").hide(0); - $(".group_title#_gte" +menuItemId).css({"color": "#"+bggroups[menuItemId].font}); - RefreshGUI(); - SaveGroups(); - } -} - // "Move to group" popup // function ShowMoveToGroupWindow(x, y) { // $(".move_to_group_menu_entry").remove(); @@ -240,111 +447,3 @@ function GroupEditConfirm() { // $("#move_to_group_menu").css({"display": "block", "top": y-24, "left": x-20}); // } - -// ********** GROUPS EVENTS *************** - -function RestoreStateOfGroupsToolbar() { - chrome.runtime.sendMessage({command: "get_group_bar", windowId: CurrentWindowId}, function(response) { - $("#toolbar_groups").css({"display": "inline-block"}); - if (response == true) { - $("#toolbar_groups").removeClass("hidden"); - $("#toolbar_groups").css({"width": "19px", "border-right": "1px solid var(--group_list_borders)"}); - } else { - $("#toolbar_groups").addClass("hidden"); - $("#toolbar_groups").css({"width": "0px", "border-right": "none"}); - } - }); -} - -function SetGroupEvents() { - - // activate group - $(document).on("click", ".group_button", function(event) { - // menuGroupId = (this.id).substr(1); - if (event.button == 0) { - SetActiveGroup((this.id).substr(1), true, true); - } - }); - - // show/hide groups toolbar - $(document).on("mousedown", "#button_groups_toolbar_hide", function(event) { - if (event.button == 0) { - $("#toolbar_groups").toggleClass("hidden"); - if ($("#toolbar_groups").is(".hidden")) { - $("#toolbar_groups").css({"width": "0px", "border-right": "none"}); - chrome.runtime.sendMessage({command: "set_group_bar", group_bar: false, windowId: CurrentWindowId}); - } else { - $("#toolbar_groups").css({"width": "19px", "border-right": "1px solid var(--group_list_borders)"}); - chrome.runtime.sendMessage({command: "set_group_bar", group_bar: true, windowId: CurrentWindowId}); - } - RefreshGUI(); - } - }); - - - // edit group dialog box - $(document).on("mousedown", "#group_edit_discard", function(event) { - $(".edit_dialog").hide(0); - }); - $("#group_edit_name").keyup(function(e) { - if (e.keyCode == 13) { - GroupEditConfirm(); - } - }); - $(document).on("mousedown", "#group_edit_confirm", function(event) { - GroupEditConfirm(); - }); - - // show color picker - $(document).on("mousedown", "#group_edit_font, #group_edit_background", function(event) { - event.stopPropagation(); - PickColor = this.id; - $("#color_picker")[0].value = "#"+RGBtoHex($(this).css("background-color")); - $("#color_picker").focus(); - $("#color_picker").click(); - }); - - $(document).on("input", "#color_picker", function(event) { - $("#"+PickColor).css({"background-color": $("#color_picker")[0].value}); - }); - - - // edit group - $(document).on("dblclick", ".group_button:not(#_tab_list)", function(event) { - if (event.button == 0) { - menuItemId = (this.id).substr(1); - ShowGroupEditWindow(); - } - }); - - - - // scroll groups - // $(document).on("mousedown", "#scroll_group_up, #scroll_group_down", function(event) { - // IOKeys.LMB = true; - // ScrollGroupList($(this).is("#scroll_group_up")); - // }); - // $(document).on("mouseleave", "#scroll_group_up, #scroll_group_down", function(event) { - // IOKeys.LMB = false; - // }); - - // remove tabs from group button - // $(document).on("mousedown", "#remove_tabs_from_group", function(event) { - // if (event.button == 0 && vt.ActiveGroup.match("at|ut") == null) { - // AppendTabsToGroup({tabsIds: $(".tab.selected_tab:visible").map(function() {return parseInt(this.id);}).toArray(), groupId: "ut", SwitchTabIfHasActive: true, insertAfter: true, moveTabs: true}); - // } - // }); - - - // remove group - // $(document).on("mousedown", ".group", function(event) { - // if (event.button == 1 || IOKeys.Shift) { - // if (IOKeys.Shift) { - // GroupRemove($(this)[0].id, true); - // } else { - // GroupRemove($(this)[0].id, false); - // } - // } - // }); - -} \ No newline at end of file diff --git a/scripts/menu.js b/scripts/menu.js index 6283c06..bee47ce 100644 --- a/scripts/menu.js +++ b/scripts/menu.js @@ -4,287 +4,681 @@ // ********** MENU *************** +function HideMenus() { + document.querySelectorAll(".separator, .menu_item").forEach(function(s){s.style.display = "none";}); + document.querySelectorAll(".menu").forEach(function(s){ + s.style.top = "-1000px"; + s.style.left = "-1000px"; + }); +} + +function ShowMenu(MenuNode, event) { + MenuNode.style.display = "block"; + let x = event.pageX >= (document.body.clientWidth - MenuNode.getBoundingClientRect().width - 5) ? (document.body.clientWidth - MenuNode.getBoundingClientRect().width - 5) : (event.pageX - 5); + let y = event.pageY >= (document.body.clientHeight - MenuNode.getBoundingClientRect().height - 16) ? (document.body.clientHeight - MenuNode.getBoundingClientRect().height - 16) : (event.pageY - 16); + MenuNode.style.top = y + "px"; + MenuNode.style.left = x + "px"; +} + function ShowTabMenu(TabNode, event) { - $(".menu").hide(0); - menuItemId = parseInt(TabNode[0].id); + HideMenus(); + menuItemNode = TabNode; + // $(".menu").hide(0); + // MUTE TABS - if (TabNode.is(".muted")) { - $("#tabs_menu_mute").css({ "display": "none" }); - $("#tabs_menu_unmute").css({ "display": "" }); + // if (TabNode.classList.contains("audible") && !TabNode.classList.contains("muted")) { + // document.querySelector("#menu_mute_tab").style.display = ""; + // } + if (TabNode.classList.contains("muted")) { + document.querySelector("#menu_unmute_tab").style.display = ""; } else { - $("#tabs_menu_mute").css({ "display": "" }); - $("#tabs_menu_unmute").css({ "display": "none" }); + document.querySelector("#menu_mute_tab").style.display = ""; } - if (TabNode.is(".pin")) { - if (!opt.allow_pin_close) { - $("#tabs_menu_close").css({ "display": "none" }); - } - // show contextmenu with correct size position - if ($("#pins_menu").outerWidth() > $(window).width() - 10) { - $("#pins_menu").css({ "width": $(window).width() - 10 }); - } else { - $("#pins_menu").css({ "width": "" }); - } - var x = event.pageX >= $(window).width() - $("#pins_menu").outerWidth() ? $(window).width() - $("#pins_menu").outerWidth() : event.pageX; - var y = event.pageY >= $(window).height() - $("#pins_menu").outerHeight() - 10 ? $(window).height() - $("#pins_menu").outerHeight() - 10 : event.pageY; - $("#pins_menu").css({ "display": "block", "top": y - 15, "left": x - 5 }); + if (!TabNode.classList.contains("discarded")) { + document.querySelector("#menu_unload").style.display = ""; } - if (TabNode.is(".tab")) { - if ($("#" + menuItemId).is(".o, .c")) { - $("#tabs_menu_close_tree").css({ "display": "" }); - } else { - $("#tabs_menu_close_tree").css({ "display": "none" }); + + if (TabNode.classList.contains("pin")) { + if (opt.allow_pin_close) { + document.getElementById("menu_close").style.display = ""; } - if ($("#tabs_menu").outerWidth() > $(window).width() - 10) { - $("#tabs_menu").css({ "width": $(window).width() - 10 }); - } else { - $("#tabs_menu").css({ "width": "" }); - } - var x = event.pageX >= $(window).width() - $("#tabs_menu").outerWidth() ? $(window).width() - $("#tabs_menu").outerWidth() : event.pageX; - var y = event.pageY >= $(window).height() - $("#tabs_menu").outerHeight() - 10 ? $(window).height() - $("#tabs_menu").outerHeight() - 10 : event.pageY; - $("#tabs_menu").css({ "display": "block", "top": y - 15, "left": x - 5 }); + + document.querySelectorAll("#menu_new_pin, #separator_unpt, #menu_unpin_tab, #separator_dupt, #menu_duplicate_tab, #separator_undclo, #menu_undo_close_tab, #separator_deta, #menu_detach_tab, #menu_reload_tab, #separator_clo, #menu_close_other, #separator_mutot, #menu_mute_other, #menu_unmute_other, #separator_tts, #menu_treetabs_settings").forEach(function(s){ + s.style.display = ""; + }); } + + if (TabNode.classList.contains("tab")) { + + document.querySelectorAll("#menu_new_tab, #separator_pit, #menu_pin_tab, #separator_newf, #menu_new_folder, #separator_dupt, #menu_duplicate_tab, #separator_undclo, #menu_undo_close_tab, #separator_expaa, #menu_expand_all, #menu_collapse_all, #separator_deta, #menu_detach_tab, #menu_reload_tab, #separator_clo, #menu_close, #menu_close_other, #separator_mut, #separator_mutot, #menu_mute_other, #menu_unmute_other, #separator_tts, #menu_treetabs_settings").forEach(function(s){ + s.style.display = ""; + }); + + if (TabNode.classList.contains("o")) { + document.querySelector("#separator_collt").style.display = ""; + document.querySelector("#menu_collapse_tree").style.display = ""; + } + if (TabNode.classList.contains("c")) { + document.querySelector("#separator_expat").style.display = ""; + document.querySelector("#menu_expand_tree").style.display = ""; + } + if (TabNode.classList.contains("c") || TabNode.classList.contains("o")) { + document.querySelector("#menu_close_tree").style.display = ""; + document.querySelector("#separator_bkt").style.display = ""; + document.querySelector("#menu_bookmark_tree").style.display = ""; + document.querySelector("#separator_mutt").style.display = ""; + document.querySelector("#menu_mute_tree").style.display = ""; + document.querySelector("#menu_unmute_tree").style.display = ""; + } + } + ShowMenu(document.getElementById("main_menu"), event); } function ShowFolderMenu(FolderNode, event) { - $(".menu").hide(0); - menuItemId = FolderNode[0].id; - if ($("#folders_menu").outerWidth() > $(window).width() - 10) { - $("#folders_menu").css({ "width": $(window).width() - 10 }); - } else { - $("#folders_menu").css({ "width": "" }); + HideMenus(); + menuItemNode = FolderNode; + + document.querySelectorAll("#menu_mute_tab, #menu_unmute_tab, #menu_unload, #menu_new_tab, #menu_new_folder, #separator_renf, #menu_rename_folder, #menu_delete_folder, #separator_bkt, #menu_bookmark_tree, #separator_expaa, #menu_expand_all, #separator_colla, #menu_collapse_all, #menu_new_group, #separator_tts, #menu_treetabs_settings").forEach(function(s){ + s.style.display = ""; + }); + + if (FolderNode.classList.contains("o")) { + document.querySelector("#folders_menu, #menu_collapse_tree").style.display = ""; } - var x = event.pageX >= $(window).width() - $("#folders_menu").outerWidth() ? $(window).width() - $("#folders_menu").outerWidth() : event.pageX; - var y = event.pageY >= $(window).height() - $("#folders_menu").outerHeight() - 10 ? $(window).height() - $("#folders_menu").outerHeight() - 10 : event.pageY; - $("#folders_menu").css({ "display": "block", "top": y - 15, "left": x - 5 }); + if (FolderNode.classList.contains("c")) { + document.querySelector("#folders_menu, #menu_expand_tree").style.display = ""; + } + + ShowMenu(document.getElementById("main_menu"), event); +} + +function ShowFGlobalMenu(event) { + menuItemNode = event.target; + HideMenus(); + + + document.querySelectorAll("#menu_new_pin, #menu_new_tab, #menu_new_folder, #separator_undclo, #menu_undo_close_tab, #separator_expaa, #menu_expand_all, #menu_collapse_all, #separator_newg, #menu_new_group, #separator_gbk, #menu_bookmark_group, #separator_tts, #menu_treetabs_settings").forEach(function(s){ + s.style.display = ""; + }); + ShowMenu(document.getElementById("main_menu"), event); +} + +function ShowFGroupMenu(GroupNode, event) { + HideMenus(); + menuItemNode = GroupNode; + + document.querySelectorAll("#menu_new_group, #menu_rename_group, #menu_delete_group, #menu_delete_group_tabs_close, #separator_gunlo, #groups_menu_unload, #separator_gbk, #separator_tts, #menu_bookmark_group, #separator_tts, #menu_treetabs_settings").forEach(function(s){ + s.style.display = ""; + }); + if (menuItemNode.id == "tab_list") { + document.querySelectorAll("#menu_rename_group, #menu_delete_group, #menu_delete_group_tabs_close").forEach(function(s){ + s.style.display = "none"; + }); + } + ShowMenu(document.getElementById("main_menu"), event); } function SetMenu() { - // trigger action when the contexmenu is about to be shown - $(document).bind("contextmenu", function(event) { - if (!event.ctrlKey) { - event.preventDefault(); - } - }); - - // show global menu - $(document).on("mousedown", "#pin_list, .group", function(event) { - event.stopPropagation(); - if (event.button == 2) { - $(".menu").hide(0); - menuItemId = active_group; - - var x = event.pageX >= $(window).width() - $("#global_menu").outerWidth() ? $(window).width() - $("#global_menu").outerWidth() : event.pageX; - var y = event.pageY >= $(window).height() - $("#global_menu").outerHeight() - 10 ? $(window).height() - $("#global_menu").outerHeight() - 10 : event.pageY; - $("#global_menu").css({ "display": "block", "top": y - 15, "left": x - 5 }); - } - }); - - // show global menu - $(document).on("mousedown", ".group_drag_box", function(event) { - // event.stopPropagation(); - if (event.button == 2) { - $(".menu").hide(0); - if (this.id == "-tab_list") { - menuItemId = "tab_list"; - $("#groups_menu_rename, #groups_menu_delete, #groups_menu_delete_tabs_close").hide(); - } else { - menuItemId = (this.id).substr(1); - $("#groups_menu_rename, #groups_menu_delete, #groups_menu_delete_tabs_close").show(); - } - var x = event.pageX >= $(window).width() - $("#groups_menu").outerWidth() ? $(window).width() - $("#groups_menu").outerWidth() : event.pageX; - var y = event.pageY >= $(window).height() - $("#groups_menu").outerHeight() - 10 ? $(window).height() - $("#groups_menu").outerHeight() - 10 : event.pageY; - $("#groups_menu").css({ "display": "block", "top": y - 15, "left": x - 5 }); - } - }); - - - - // if the menu element is clicked - $(document).on("mousedown", ".menu li", function(event) { - event.stopPropagation(); - if (event.button != 0) { - return; - } - switch ($(this).attr("data-action")) { - case "tab_new": - chrome.tabs.create({}); - break; - case "tab_clone": - if ($("#" + menuItemId).is(".selected_tab")) { - $(".selected_tab:visible").each(function() { - chrome.tabs.duplicate(parseInt(this.id)); - }); - } else { - chrome.tabs.duplicate(menuItemId); + document.querySelectorAll(".menu_item").forEach(function(m){ + if (m.id == "menu_new_pin") { + m.onmousedown = function(event) { + if (event.which == 1) { + event.stopPropagation(); + if (menuItemNode.classList.contains("pin")) { + OpenNewTab(true, menuItemNode.id); + } else { + OpenNewTab(true, undefined); + } + HideMenus(); } - break; - case "tab_move": - if ($("#" + menuItemId).is(".selected_tab, .active_tab")) { + } + } + if (m.id == "menu_new_tab") { + m.onmousedown = function(event) { + if (event.which == 1) { + event.stopPropagation(); + if (menuItemNode.classList.contains("folder")) { + OpenNewTab(false, menuItemNode.id); + } else { + if (menuItemNode.classList.contains("pin")) { + OpenNewTab(true, menuItemNode.id); + } else { + if (menuItemNode.classList.contains("tab")) { + OpenNewTab(false, menuItemNode.id); + } else { + OpenNewTab(); + } + } + } + HideMenus(); + } + } + } + + if (m.id == "menu_unpin_tab" || m.id == "menu_pin_tab") { + m.onmousedown = function(event) { + event.stopPropagation(); + if (event.which == 1) { + if (menuItemNode.classList.contains("selected_tab")) { + document.querySelectorAll(".pin.selected_tab, #"+active_group+" .selected_tab").forEach(function(s){ + chrome.tabs.update(parseInt(s.id), { pinned: (menuItemNode.classList.contains("tab")) }); + }); + } else { + chrome.tabs.update(parseInt(menuItemNode.id), { pinned: (menuItemNode.classList.contains("tab")) }); + } + HideMenus(); + } + } + } + + if (m.id == "menu_duplicate_tab") { + m.onmousedown = function(event) { + event.stopPropagation(); + if (event.which == 1) { + if (menuItemNode.classList.contains("selected_tab")) { + document.querySelectorAll(".pin.selected_tab, #"+active_group+" .selected_tab").forEach(function(s){ + chrome.tabs.duplicate(parseInt(s.id), function(tab) { + setTimeout(function() { + let tb = document.getElementById(tab.id); + if (s != null && tb != null) { + s.parentNode.insertBefore(tb, s); + } + }, 10); + }); + }); + } else { + chrome.tabs.duplicate(parseInt(menuItemNode.id), function(tab) { + setTimeout(function() { + let tb = document.getElementById(tab.id); + if (menuItemNode != null && tb != null) { + menuItemNode.parentNode.insertBefore(tb, menuItemNode); + } + }, 10); + }); + } + HideMenus(); + } + } + } + + if (m.id == "menu_detach_tab") { + m.onmousedown = function(event) { + if (event.which == 1) { + event.stopPropagation(); + + if (menuItemNode.classList.contains("selected_tab")) { + let tabsArr = []; + document.querySelectorAll(".pin.selected_tab, #"+active_group+" .selected_tab").forEach(function(s){ + tabsArr.push(parseInt(s.id)); + if (s.childNodes[4].childNodes.length > 0) { + document.querySelectorAll("#"+s.childNodes[4].id+" .tab").forEach(function(t){ + tabsArr.push(parseInt(t.id)); + }); + } + }); + Detach(tabsArr); + } else { + Detach([parseInt(menuItemNode.id)]); + } + HideMenus(); + } + } + } + + if (m.id == "menu_reload_tab") { + m.onmousedown = function(event) { + if (event.which == 1) { + event.stopPropagation(); + if (menuItemNode.classList.contains("selected_tab")) { + document.querySelectorAll(".pin.selected_tab, #"+active_group+" .selected_tab").forEach(function(s){ + chrome.tabs.reload(parseInt(s.id)); + }); + } else { + chrome.tabs.reload(parseInt(menuItemNode.id)); + } + HideMenus(); + } + } + } + + if (m.id == "menu_unload") { + m.onmousedown = function(event) { + if (event.which == 1) { + event.stopPropagation(); + if (menuItemNode.classList.contains("pin") || menuItemNode.classList.contains("tab")) { + if (menuItemNode.classList.contains("selected_tab")) { + let tabsArr = []; + document.querySelectorAll(".pin.selected_tab, #"+active_group+" .selected_tab").forEach(function(s){ + tabsArr.push(parseInt(s.id)); + if (s.childNodes[4].childNodes.length > 0) { + document.querySelectorAll("#"+s.childNodes[4].id+" .tab").forEach(function(t){ + tabsArr.push(parseInt(t.id)); + }); + } + }); + DiscardTabs(tabsArr); + } else { + DiscardTabs([parseInt(menuItemNode.id)]); + } + } + if (menuItemNode.classList.contains("folder")) { + let tabsArr = []; + document.querySelectorAll("#"+menuItemNode.id+" .tab").forEach(function(s){ + tabsArr.push(parseInt(s.id)); + }); + DiscardTabs(tabsArr); + } + HideMenus(); + } + } + } + + if (m.id == "menu_close") { + m.onmousedown = function(event) { + if (event.which == 1) { + event.stopPropagation(); + if (menuItemNode.classList.contains("selected_tab")) { + let tabsArr = []; + document.querySelectorAll(".pin.selected_tab, #"+active_group+" .selected_tab").forEach(function(s){ + tabsArr.push(parseInt(s.id)); + if (s.childNodes[4].childNodes.length > 0) { + document.querySelectorAll("#"+s.childNodes[4].id+" .tab").forEach(function(t){ + tabsArr.push(parseInt(t.id)); + }); + } + }); + CloseTabs(tabsArr); + } else { + CloseTabs([parseInt(menuItemNode.id)]); + } + HideMenus(); + } + } + } + + if (m.id == "menu_mute_tab") { + m.onmousedown = function(event) { + if (event.which == 1) { + event.stopPropagation(); + if (menuItemNode.classList.contains("pin") || menuItemNode.classList.contains("tab")) { + if (menuItemNode.classList.contains("selected_tab")) { + document.querySelectorAll(".pin.selected_tab, #"+active_group+" .selected_tab").forEach(function(s){ + chrome.tabs.update(parseInt(s.id), { muted: true }); + }); + } else { + chrome.tabs.update(parseInt(menuItemNode.id), { muted: true }); + } + } + if (menuItemNode.classList.contains("folder")) { + document.querySelectorAll("#"+menuItemNode.id+" .tab").forEach(function(s){ + chrome.tabs.update(parseInt(s.id), { muted: true }); + }); + } + HideMenus(); + } + } + } + + if (m.id == "menu_mute_tree") { + m.onmousedown = function(event) { + if (event.which == 1) { + event.stopPropagation(); + document.querySelectorAll("[id='"+menuItemNode.id+"'], [id='"+menuItemNode.id+"'] .tab").forEach(function(s){ + chrome.tabs.update(parseInt(s.id), { muted: true }); + }); + HideMenus(); + } + } + } + + if (m.id == "menu_unmute_tab") { + m.onmousedown = function(event) { + if (event.which == 1) { + event.stopPropagation(); + if (menuItemNode.classList.contains("pin") || menuItemNode.classList.contains("tab")) { + if (menuItemNode.classList.contains("selected_tab")) { + document.querySelectorAll(".pin.selected_tab, #"+active_group+" .selected_tab").forEach(function(s){ + chrome.tabs.update(parseInt(s.id), { muted: false }); + }); + } else { + chrome.tabs.update(parseInt(menuItemNode.id), { muted: false }); + } + } + if (menuItemNode.classList.contains("folder")) { + document.querySelectorAll("#"+menuItemNode.id+" .tab").forEach(function(s){ + chrome.tabs.update(parseInt(s.id), { muted: false }); + }); + } + HideMenus(); + } + } + } + + if (m.id == "menu_unmute_tree") { + m.onmousedown = function(event) { + if (event.which == 1) { + event.stopPropagation(); + document.querySelectorAll("[id='"+menuItemNode.id+"'], [id='"+menuItemNode.id+"'] .tab").forEach(function(s){ + chrome.tabs.update(parseInt(s.id), { muted: false }); + }); + HideMenus(); + } + } + } + + + if (m.id == "menu_mute_other") { + m.onmousedown = function(event) { + if (event.which == 1) { + event.stopPropagation(); + if (menuItemNode.classList.contains("selected_tab")) { + document.querySelectorAll(".pin:not(.selected_tab), #"+active_group+" .tab:not(.selected_tab)").forEach(function(s){ + chrome.tabs.update(parseInt(s.id), { muted: true }); + }); + } else { + document.querySelectorAll(".pin:not([id='"+menuItemNode.id+"']), #"+active_group+" .tab:not([id='"+menuItemNode.id+"'])").forEach(function(s){ + chrome.tabs.update(parseInt(s.id), { muted: true }); + }); + } + + HideMenus(); + } + } + } + + + if (m.id == "menu_unmute_other") { + m.onmousedown = function(event) { + if (event.which == 1) { + event.stopPropagation(); + if (menuItemNode.classList.contains("selected_tab")) { + document.querySelectorAll(".pin:not(.selected_tab), #"+active_group+" .tab:not(.selected_tab)").forEach(function(s){ + chrome.tabs.update(parseInt(s.id), { muted: false }); + }); + } else { + document.querySelectorAll(".pin:not([id='"+menuItemNode.id+"']), #"+active_group+" .tab:not([id='"+menuItemNode.id+"'])").forEach(function(s){ + chrome.tabs.update(parseInt(s.id), { muted: false }); + }); + } + HideMenus(); + } + } + } + + + + + if (m.id == "menu_undo_close_tab") { + m.onmousedown = function(event) { + if (event.which == 1) { + event.stopPropagation(); + chrome.sessions.getRecentlyClosed(null, function(sessions) { + if (sessions.length > 0) { + chrome.sessions.restore(null, function() {}); + } + }); + HideMenus(); + } + } + } + + + if (m.id == "menu_new_folder") { + m.onmousedown = function(event) { + if (event.which == 1) { + event.stopPropagation(); + if (menuItemNode.classList.contains("folder")) { + AddNewFolder(menuItemNode.id, undefined, undefined, undefined); + } else { + if (menuItemNode.classList.contains("tab")) { + let folders = GetParentsByClass(menuItemNode, "folder"); + if (folders.length > 0) { + AddNewFolder(folders[0].id, undefined, undefined, undefined); + } else { + AddNewFolder(); + } + } else { + AddNewFolder(); + } + } + HideMenus(); + } + } + } + + + if (m.id == "menu_expand_tree") { + m.onmousedown = function(event) { + if (event.which == 1) { + event.stopPropagation(); + document.querySelectorAll("[id='"+menuItemNode.id+"'], [id='"+menuItemNode.id+"'] .folder.c, [id='"+menuItemNode.id+"'] .tab.c").forEach(function(s){ + s.classList.add("o"); + s.classList.remove("c"); + }); + + schedule_update_data++; + HideMenus(); + } + } + } + + if (m.id == "menu_collapse_tree") { + m.onmousedown = function(event) { + if (event.which == 1) { + event.stopPropagation(); + document.querySelectorAll("[id='"+menuItemNode.id+"'], [id='"+menuItemNode.id+"'] .folder.c, [id='"+menuItemNode.id+"'] .tab.c").forEach(function(s){ + s.classList.add("c"); + s.classList.remove("o"); + }); + schedule_update_data++; + HideMenus(); + } + } + } + + if (m.id == "menu_expand_all") { + m.onmousedown = function(event) { + if (event.which == 1) { + event.stopPropagation(); + document.querySelectorAll("#"+active_group+" .folder.c, #"+active_group+" .tab.c").forEach(function(s){ + s.classList.add("o"); + s.classList.remove("c"); + }); + schedule_update_data++; + HideMenus(); + } + } + } + + if (m.id == "menu_collapse_all") { + m.onmousedown = function(event) { + if (event.which == 1) { + event.stopPropagation(); + document.querySelectorAll("#"+active_group+" .folder.o, #"+active_group+" .tab.o").forEach(function(s){ + s.classList.add("c"); + s.classList.remove("o"); + }); + schedule_update_data++; + HideMenus(); + } + } + } + + + + if (m.id == "menu_close_tree") { + m.onmousedown = function(event) { + if (event.which == 1) { + event.stopPropagation(); + let tabsArr = []; - $(".active_tab:visible, .selected_tab:visible").each(function() { - tabsArr.push(parseInt(this.id)); - if ($("#ch"+this.id).children().length > 0) { - $($("#ch"+this.id).find(".tab")).each(function() { - tabsArr.push(parseInt(this.id)); + document.querySelectorAll("[id='"+menuItemNode.id+"'] .tab, [id='"+menuItemNode.id+"']").forEach(function(s){ + tabsArr.push(parseInt(s.id)); + if (s.childNodes[4].childNodes.length > 0) { + document.querySelectorAll("#"+s.childNodes[4].id+" .tab").forEach(function(t){ + tabsArr.push(parseInt(t.id)); }); } }); - DetachTabs(tabsArr); - } else { - DetachTabs([menuItemId]); + CloseTabs(tabsArr); + HideMenus(); } - break; - case "tab_reload": - if ($("#" + menuItemId).is(".selected_tab")) { - $(".selected_tab:visible").each(function() { - chrome.tabs.reload(parseInt(this.id)); - }); - } else { - chrome.tabs.reload(menuItemId); - } - break; - case "tab_pin": - if ($("#" + menuItemId).is(".selected_tab")) { - $(".selected_tab:visible").each(function() { - chrome.tabs.update(parseInt(this.id), { pinned: ($("#" + menuItemId).is(".pin") ? false : true) }); - }); - } else { - chrome.tabs.update(menuItemId, { pinned: ($("#" + menuItemId).is(".pin") ? false : true) }); - } - break; - case "tab_mute": - if ($("#" + menuItemId).is(".selected_tab")) { - $(".selected_tab:visible").each(function() { - chrome.tabs.get(parseInt(this.id), function(tab) { - if (tab) { - chrome.tabs.update(tab.id, { muted: true }); - } - }); - }); - } else { - chrome.tabs.get(menuItemId, function(tab) { - if (tab) { - chrome.tabs.update(tab.id, { muted: true }); - } - }); - } - break; - case "tab_unmute": - if ($("#" + menuItemId).is(".selected_tab")) { - $(".selected_tab:visible").each(function() { - chrome.tabs.get(parseInt(this.id), function(tab) { - if (tab) { - chrome.tabs.update(tab.id, { muted: false }); - } - }); - }); - } else { - chrome.tabs.get(menuItemId, function(tab) { - chrome.tabs.update(tab.id, { muted: false }); - }); - } - break; - case "tab_mute_other": - if ($("#" + menuItemId).is(".selected_tab")) { - $(".tab:visible:not(.selected_tab)").each(function() { - chrome.tabs.update(parseInt(this.id), { muted: true }); - }); - } else { - $(".tab:visible:not(#" + menuItemId + ")").each(function() { - chrome.tabs.update(parseInt(this.id), { muted: true }); - }); - } - break; - case "tab_unmute_other": - if ($("#" + menuItemId).is(".selected_tab")) { - $(".tab:visible:not(.selected_tab)").each(function() { - chrome.tabs.update(parseInt(this.id), { muted: false }); - }); - } else { - $(".tab:visible:not(#" + menuItemId + ")").each(function() { - chrome.tabs.update(parseInt(this.id), { muted: false }); - }); - } - break; - case "tab_close": - CloseTabs($("#" + menuItemId).is(".selected_tab") ? $(".selected_tab:visible").map(function() { return parseInt(this.id); }).toArray() : [menuItemId]); - break; - case "tab_close_tree": - CloseTabs($("#" + menuItemId).find(".tab").map(function() { return parseInt(this.id); }).toArray()); - CloseTabs([menuItemId]); - break; - case "tab_close_other": - CloseTabs($(".tab:visible:not(#" + menuItemId + ")").map(function() { return parseInt(this.id); }).toArray()); - break; - case "tab_undo_close": - chrome.sessions.getRecentlyClosed(null, function(sessions) { - if (sessions.length > 0) { - chrome.sessions.restore(null, function() {}); - } - }); - break; - case "tab_discard": - DiscardTabs($("#" + menuItemId).is(".selected_tab") ? $(".tab.selected_tab:visible").map(function() { return parseInt(this.id); }).toArray() : [menuItemId]); - break; - case "tab_settings": - chrome.tabs.create({ "url": "options.html" }); - break; - case "tab_expand_all": - $(".tab.c").addClass("o").removeClass("c"); - schedule_update_data++; - break; - case "tab_collapse_all": - $(".tab.o").addClass("c").removeClass("o"); - schedule_update_data++; - break; - case "folder_new": - AddNewFolder({}); - break; - case "folder_rename": - if ($("#" + menuItemId).is(".selected_folder")) { - $(".selected_folder:visible").each(function() { - ShowRenameFolderDialog(this.id); - }); - } else { - ShowRenameFolderDialog(menuItemId); - } - break; - case "folder_delete": - if ($("#" + menuItemId).is(".selected_folder")) { - $(".selected_folder:visible").each(function() { - RemoveFolder(this.id); - }); - } else { - RemoveFolder(menuItemId); - } - break; - case "group_new": - AddNewGroup({}); - break; - case "group_rename": - ShowGroupEditWindow(); - break; - case "group_delete": - GroupRemove(menuItemId, false); - break; - case "group_delete_tabs_close": - GroupRemove(menuItemId, true); - break; - case "group_unload": - DiscardTabs($("#"+menuItemId+" .tab").map(function() { return parseInt(this.id); }).toArray()); - break; + } } - $(".menu").hide(0); + + if (m.id == "menu_rename_folder") { + m.onmousedown = function(event) { + if (event.which == 1) { + event.stopPropagation(); + ShowRenameFolderDialog(menuItemNode.id); + HideMenus(); + } + } + } + + + if (m.id == "menu_delete_folder") { + m.onmousedown = function(event) { + if (event.which == 1) { + event.stopPropagation(); + if (menuItemNode.classList.contains("selected_folder")) { + document.querySelectorAll("#"+menuItemNode.id+" .selected_folder, #"+menuItemNode.id).forEach(function(s){ + RemoveFolder(s.id); + }); + } else { + RemoveFolder(menuItemNode.id); + } + HideMenus(); + } + } + } + + if (m.id == "menu_close_other") { + m.onmousedown = function(event) { + if (event.which == 1) { + event.stopPropagation(); + let tabsArr = []; + if (menuItemNode.classList.contains("selected_tab")) { + document.querySelectorAll(".pin:not(.selected_tab), #"+active_group+" .tab:not(.selected_tab)").forEach(function(s){ + let children = document.querySelectorAll("[id='"+s.id+"'] .selected_tab"); + if (children.length == 0 || opt.promote_children) { + tabsArr.push(parseInt(s.id)); + } + }); + CloseTabs(tabsArr); + } else { + if (menuItemNode.classList.contains("tab")) { + document.getElementById(active_group).appendChild(menuItemNode); + } + document.querySelectorAll(".pin:not([id='"+menuItemNode.id+"']), #"+active_group+" .tab:not([id='"+menuItemNode.id+"'])").forEach(function(s){ + tabsArr.push(parseInt(s.id)); + }); + + CloseTabs(tabsArr); + } + HideMenus(); + } + } + } + + if (m.id == "menu_bookmark_tree") { + m.onmousedown = function(event) { + if (event.which == 1) { + event.stopPropagation(); + Bookmark(menuItemNode); + HideMenus(); + } + } + } + + + if (m.id == "menu_rename_group") { + m.onmousedown = function(event) { + if (event.which == 1) { + event.stopPropagation(); + ShowGroupEditWindow(menuItemNode.id); + HideMenus(); + } + } + } + + if (m.id == "menu_delete_group") { + m.onmousedown = function(event) { + if (event.which == 1) { + event.stopPropagation(); + GroupRemove(menuItemNode.id, false); + HideMenus(); + } + } + } + + + if (m.id == "menu_delete_group_tabs_close") { + m.onmousedown = function(event) { + if (event.which == 1) { + event.stopPropagation(); + GroupRemove(menuItemNode.id, true); + HideMenus(); + } + } + } + + + if (m.id == "groups_menu_unload") { + m.onmousedown = function(event) { + if (event.which == 1) { + event.stopPropagation(); + let tabsArr = []; + document.querySelectorAll("[id='"+menuItemNode.id+"'] .tab").forEach(function(s){ + tabsArr.push(parseInt(s.id)); + }); + DiscardTabs(tabsArr); + HideMenus(); + } + } + } + + + if (m.id == "menu_bookmark_group") { + m.onmousedown = function(event) { + if (event.which == 1) { + event.stopPropagation(); + Bookmark(menuItemNode); + HideMenus(); + } + } + } + + if (m.id == "menu_new_group") { + m.onmousedown = function(event) { + if (event.which == 1) { + event.stopPropagation(); + AddNewGroup(); + HideMenus(); + } + } + } + + + if (m.id == "menu_treetabs_settings") { + m.onmousedown = function(event) { + if (event.which == 1) { + event.stopPropagation(); + chrome.tabs.create({ "url": "options.html" }); + HideMenus(); + } + } + } + + }); - // move tabs to group - // $(document).on("mousedown", "#tabs_menu_move_to_new_group, .move_to_group_menu_entry", function(event) { + // $(document).on("mousedown", "#menu_detach_tab_to_new_group, .move_to_group_menu_entry", function(event) { // var tabsIds - // if ($(this).is("#tabs_menu_move_to_new_group")) { + // if ($(this).is("#menu_detach_tab_to_new_group")) { // bg.dt.DropToGroup = AddNewGroup(575757); // GetColorFromMiddlePixel(vt.menuItemId, bg.dt.DropToGroup); // } else { diff --git a/scripts/refresh.js b/scripts/refresh.js index 83775f1..4553196 100644 --- a/scripts/refresh.js +++ b/scripts/refresh.js @@ -4,64 +4,80 @@ // ********** REFRESH GUI *************** -function SetTRefreshEvents() { - $(window).on("resize", function(event) { - RefreshGUI(); - }); - - // click on media icon - $(document).on("mousedown", ".tab_mediaicon", function(event) { - event.stopPropagation(); - if (event.button == 0 && $(this).parent().parent().is(".audible, .muted")) { - chrome.tabs.get(parseInt(this.parentNode.parentNode.id), function(tab) { - if (tab) { - chrome.tabs.update(tab.id, {muted:!tab.mutedInfo.muted}); - } - }); - } - }); -} - function RefreshGUI() { - if ($("#toolbar").children().length > 0) { - $("#toolbar").css({ "height": "", "width": "", "display": "", "padding": "", "border": "" }); - if ($(".button").is(".on")) { - $("#toolbar").css({ "height": 53 }); + let toolbar = document.getElementById("toolbar"); + if (toolbar.children.length > 0) { + toolbar.style.height = ""; + toolbar.style.width = ""; + toolbar.style.display = ""; + toolbar.style.border = ""; + toolbar.style.padding = ""; + if (document.querySelector(".on.button") != null) { + toolbar.style.height = "53px"; } else { - $("#toolbar").css({ "height": 26 }); + toolbar.style.height = "26px"; } } else { - $("#toolbar").css({ "height": 0, "width": "0px", "display": "none", "padding": "0", "border": "none" }); + toolbar.style.height = "0px"; + toolbar.style.width = "0px"; + toolbar.style.display = "none"; + toolbar.style.border = "none"; + toolbar.style.padding = "0"; } - - if ($("#pin_list").children().length > 0) { - $("#pin_list").css({ "top": $("#toolbar")[0].getBoundingClientRect().height, "height": "", "width":"", "display": "", "padding": "", "border": "" }); + let pin_list = document.getElementById("pin_list"); + if (pin_list.children.length > 0) { + pin_list.style.top = toolbar.getBoundingClientRect().height + "px"; + pin_list.style.height = ""; + pin_list.style.width = document.body.clientWidth + "px";; + pin_list.style.display = ""; + pin_list.style.border = ""; + pin_list.style.padding = ""; } else { - $("#pin_list").css({ "height": "0px", "width": "0px", "display": "none", "padding": "0", "border": "none" }); + pin_list.style.top = "0px"; + pin_list.style.height = "0px"; + pin_list.style.width = "0px"; + pin_list.style.display = "none"; + pin_list.style.border = "none"; + pin_list.style.padding = "0"; } - - $("#toolbar_groups").css({ "top": $("#toolbar").outerHeight() + $("#pin_list")[0].getBoundingClientRect().height, "height": $(window).height() - $("#toolbar").outerHeight() - $("#pin_list")[0].getBoundingClientRect().height}); - - $(".group_title").each(function(){ - $(this)[0].innerText = (bggroups[(this.id).substr(4)] ? bggroups[(this.id).substr(4)].name : caption_noname_group) + (opt.show_counter_groups ? " (" + $("#" + (this.id).substr(4) +" .tab").length + ")" : ""); + let toolbar_groups = document.getElementById("toolbar_groups"); + toolbar_groups.style.top = toolbar.getBoundingClientRect().height + pin_list.getBoundingClientRect().height + "px"; + toolbar_groups.style.height = document.body.clientHeight - toolbar.getBoundingClientRect().height - pin_list.getBoundingClientRect().height + "px"; + if (opt.show_counter_groups) { + document.querySelectorAll(".group").forEach(function(s){ + let groupLabel = document.getElementById("_gte"+s.id); + if (groupLabel) { + groupLabel.textContent = (bggroups[s.id] ? bggroups[s.id].name : caption_noname_group) + " (" + document.querySelectorAll("#"+s.id+" .tab").length + ")"; + } + }); + } else { + document.querySelectorAll(".group").forEach(function(s){ + let groupLabel = document.getElementById("_gte"+s.id); + if (groupLabel) { + groupLabel.textContent = bggroups[s.id] ? bggroups[s.id].name : caption_noname_group; + } + }); + } + document.querySelectorAll(".group_button").forEach(function(s){ + s.style.height = s.firstChild.getBoundingClientRect().height + "px"; }); - - $(".group_button").each(function(){ - $(this).css({ "height": $(this).children(0).innerWidth() }); - }); - - $("#groups").css({ "top": $("#toolbar")[0].getBoundingClientRect().height + $("#pin_list")[0].getBoundingClientRect().height, "left": $("#toolbar_groups").outerWidth(), "height": $(window).height() - $("#pin_list")[0].getBoundingClientRect().height - $("#toolbar").outerHeight(), "width": $(window).width() - $("#toolbar_groups").outerWidth() }); + let groups = document.getElementById("groups"); + groups.style.top = toolbar.getBoundingClientRect().height + pin_list.getBoundingClientRect().height + "px"; + groups.style.left = toolbar_groups.getBoundingClientRect().width + "px"; + groups.style.height = document.body.clientHeight - pin_list.getBoundingClientRect().height - toolbar.getBoundingClientRect().height + "px"; + groups.style.width = document.body.clientWidth - toolbar_groups.getBoundingClientRect().width + 1 + "px"; } // set discarded class function RefreshDiscarded(tabId) { - if ($("#" + tabId).length > 0) { + let t = document.getElementById(tabId); + if (t != null) { chrome.tabs.get(parseInt(tabId), function(tab) { if (tab) { if (tab.discarded) { - $("#" + tabId).addClass("discarded"); + t.classList.add("discarded"); } else { - $("#" + tabId).removeClass("discarded"); + t.classList.remove("discarded"); } } }); @@ -70,24 +86,29 @@ function RefreshDiscarded(tabId) { // set discarded class function SetAttentionIcon(tabId) { - if ($("#" + tabId).length > 0) { - $("#" + tabId).addClass("attention"); + let t = document.getElementById(tabId); + if (t != null) { + t.classList.add("attention"); } } // change media icon function RefreshMediaIcon(tabId) { - if ($("#" + tabId).length > 0) { + let t = document.getElementById(tabId); + if (t != null) { chrome.tabs.get(parseInt(tabId), function(tab) { if (tab) { if (tab.mutedInfo.muted) { - $("#" + tabId).removeClass("audible").addClass("muted"); + t.classList.remove("audible"); + t.classList.add("muted"); } if (!tab.mutedInfo.muted && tab.audible) { - $("#" + tabId).removeClass("muted").addClass("audible"); + t.classList.remove("muted"); + t.classList.add("audible"); } if (!tab.mutedInfo.muted && !tab.audible) { - $("#" + tabId).removeClass("audible").removeClass("muted"); + t.classList.remove("audible"); + t.classList.remove("muted"); } } }); @@ -99,68 +120,73 @@ function RefreshMediaIcon(tabId) { function VivaldiRefreshMediaIcons() { setInterval(function() { chrome.tabs.query({currentWindow: true}, function(tabs) { - $(".audible, .muted").removeClass("audible").removeClass("muted"); + document.querySelectorAll(".audible, .muted").forEach(function(s){ + s.classList.remove("audible"); + s.classList.remove("muted"); + }); let tc = tabs.length; for (var ti = 0; ti < tc; ti++) { if (tabs[ti].audible) { - $("#" + tabs[ti].id).addClass("audible"); + document.getElementById(tabs[ti].id).classList.add("audible"); } if (tabs[ti].mutedInfo.muted) { - $("#" + tabs[ti].id).addClass("muted"); + document.getElementById(tabs[ti].id).classList.add("muted"); } } }); - }, 1400); + // }, 1400); + }, 1000); } function GetFaviconAndTitle(tabId, addCounter) { - if ($("#" + tabId)[0]) { + let t = document.getElementById(tabId); + if (t != null) { chrome.tabs.get(parseInt(tabId), function(tab) { if (tab){ let title = tab.title ? tab.title : tab.url; + let tHeader = t.childNodes[3]; + let tTitle = tHeader.childNodes[1]; if (tab.status == "complete") { - $("#" + tabId).removeClass("loading"); + t.classList.remove("loading"); // change title - $("#tab_title" + tab.id)[0].textContent = title; - $("#tab_header" + tab.id).attr("title", title); - $("#"+tabId).data("title", title); - + tTitle.textContent = title; + tHeader.title = title; + tHeader.setAttribute("tabTitle", title); // compatibility with various Tab suspender extensions if (tab.favIconUrl != undefined && tab.favIconUrl.match("data:image/png;base64") != null) { - $("#tab_header" + tab.id).css({ "background-image": "url(" + tab.favIconUrl + ")" }); + tHeader.style.backgroundImage = "url(" + tab.favIconUrl + ")"; } else { // case for internal pages, favicons don't have access, but can be loaded from url if (tab.url.match("opera://|vivaldi://|browser://|chrome://|chrome-extension://") != null) { - $("#tab_header" + tab.id).css({ "background-image": "url(chrome://favicon/" + tab.url + ")" }); + tHeader.style.backgroundImage = "url(chrome://favicon/" + tab.url + ")"; } else { // change favicon - var img = new Image(); + let img = new Image(); img.src = tab.favIconUrl; img.onload = function() { - $("#tab_header" + tab.id).css({ "background-image": "url(" + tab.favIconUrl + ")" }); + tHeader.style.backgroundImage = "url(" + tab.favIconUrl + ")"; }; img.onerror = function() { - $("#tab_header" + tab.id).css({ "background-image": ((tab.url == "" || browserId == "F") ? "url(./theme/icon_empty.svg)" : ("url(chrome://favicon/" + tab.url + ")")) }); - // $("#tab_header" + tab.id).css({ "background-image": "url(" + tab.url + ")" }); + tHeader.style.backgroundImage = ((tab.url == "" || browserId == "F") ? "url(./theme/icon_empty.svg)" : ("url(chrome://favicon/" + tab.url + ")")); + // "url(" + tab.url + ")" } } } } if (tab.status == "loading") { - $("#tab_header" + tab.id).css({ "background-image": "" }); - $("#" + tabId).addClass("loading"); title = tab.title ? tab.title : caption_loading; - $("#tab_title" + tab.id)[0].textContent = title; - $("#tab_header" + tab.id).attr("title", title); - $("#"+tabId).data("title", title); + t.classList.add("loading"); + tHeader.style.backgroundImage = ""; + tHeader.title = caption_loading; + tHeader.setAttribute("tabTitle", caption_loading); + tTitle.textContent = caption_loading; setTimeout(function() { - if ($("#" + tabId)[0]) GetFaviconAndTitle(tabId, addCounter); + if (document.getElementById(tab.id) != null) GetFaviconAndTitle(tab.id, addCounter); }, 1000); } if (addCounter && (opt.show_counter_tabs || opt.show_counter_tabs_hints)) { RefreshTabCounter(tabId); } - } }); } @@ -168,22 +194,23 @@ function GetFaviconAndTitle(tabId, addCounter) { // refresh open closed trees states function RefreshExpandStates() { - $(".folder:visible").each(function() { - if ($("#ch"+this.id).children().length == 0 && $("#cf"+this.id).children().length == 0) { - $(this).removeClass("o").removeClass("c").addClass("n"); + document.querySelectorAll("#"+active_group+" .folder").forEach(function(s){ + if (s.childNodes[4].children.length == 0 && s.childNodes[5].children.length == 0) { + s.classList.remove("o"); + s.classList.remove("c"); } else { - if ($(this).is(":not(.o, .c)")) { - $(this).addClass("o").removeClass("n"); + if (s.classList.contains("o") == false && s.classList.contains("c") == false) { + s.classList.add("o"); } } }); - - $(".tab:visible").each(function() { - if ($("#ch"+this.id).children().length == 0) { - $(this).removeClass("o").removeClass("c").addClass("n"); + document.querySelectorAll("#"+active_group+" .tab").forEach(function(s){ + if (s.childNodes[4].children.length == 0) { + s.classList.remove("o"); + s.classList.remove("c"); } else { - if ($(this).is(":not(.o, .c)")) { - $(this).addClass("o").removeClass("n"); + if (s.classList.contains("o") == false && s.classList.contains("c") == false) { + s.classList.add("o"); } } }); @@ -191,48 +218,50 @@ function RefreshExpandStates() { function RefreshCounters() { if (opt.show_counter_tabs || opt.show_counter_tabs_hints) { - $(".tab.n:visible").each(function() { - if ($("#tab_title"+this.id)[0]) { - $("#tab_title"+this.id)[0].textContent = $(this).data("title"); - $("#tab_header"+this.id).attr("title", $(this).data("title")); + document.querySelectorAll("#"+active_group+" .tab").forEach(function(s){ + let title = s.childNodes[3].getAttribute("tabTitle"); + if (title != null) { + s.childNodes[3].title = title; + s.childNodes[3].childNodes[1].textContent =title; } }); - $(".tab.c:visible, .tab.o:visible").each(function() { - if (opt.show_counter_tabs) { - $("#tab_title"+this.id)[0].textContent = ("("+$("#"+this.id+" .tab").length+") ") + $(this).data("title"); + document.querySelectorAll("#"+active_group+" .o.tab, #"+active_group+" .c.tab").forEach(function(s){ + let title = s.childNodes[3].getAttribute("tabTitle"); + + if (opt.show_counter_tabs && title != null) { + s.childNodes[3].childNodes[1].textContent = ("("+ document.querySelectorAll("[id='" + s.id + "'] .tab").length +") ") + title; } if (opt.show_counter_tabs_hints) { - $("#tab_header"+this.id).attr("title", ("("+$("#"+this.id+" .tab").length+") ") + $(this).data("title")); + s.childNodes[3].title = ("("+ document.querySelectorAll("[id='" + s.id + "'] .tab").length +") ") + title; } }); - $(".folder:visible").each(function() { - if (opt.show_counter_tabs) { - $("#folder_title"+this.id)[0].textContent = ("("+$("#"+this.id+" .tab").length+") ") + bgfolders[this.id].name; + + + document.querySelectorAll("#"+active_group+" .folder").forEach(function(s){ + if (opt.show_counter_tabs && bgfolders[s.id]) { + s.childNodes[3].childNodes[1].textContent = ("("+ document.querySelectorAll("[id='" + s.id + "'] .tab").length +") ") + bgfolders[s.id].name; } - if (opt.show_counter_tabs_hints) { - $("#folder_header"+this.id).attr("title", ("("+$("#"+this.id+" .tab").length+") ") + bgfolders[this.id].name); + if (opt.show_counter_tabs_hints && bgfolders[s.id]) { + s.childNodes[3].title = ("("+ document.querySelectorAll("[id='" + s.id + "'] .tab").length +") ") + bgfolders[s.id].name; } }); } } function RefreshTabCounter(tabId) { - if (opt.show_counter_tabs || opt.show_counter_tabs_hints) { - if ($("#"+tabId).data("title")) { + let t = document.getElementById(tabId); + let title = t.childNodes[3].getAttribute("tabTitle"); + if (t != null && title != null) { + if (t.classList.contains("o") || t.classList.contains("c")) { if (opt.show_counter_tabs) { - if ($(".c#"+tabId+", .o#"+tabId)[0]) { - $("#tab_title"+tabId)[0].textContent = ("("+$("#ch"+tabId+" .tab").length+") ") + $("#"+tabId).data("title"); - } else { - $("#tab_title"+tabId)[0].textContent = $("#"+tabId).data("title"); - } + t.childNodes[3].childNodes[1].textContent = ("("+ document.querySelectorAll("[id='" + t.id + "'] .tab").length +") ") + title; } if (opt.show_counter_tabs_hints) { - if ($(".c#"+tabId+", .o#"+tabId)[0]) { - $("#tab_header"+tabId).attr("title", ("("+$("#ch"+tabId+" .tab").length+") ") + $("#"+tabId).data("title")); - } else { - $("#tab_header"+tabId).attr("title", $("#"+tabId).data("title")); - } + t.childNodes[3].title = ("("+ document.querySelectorAll("[id='" + t.id + "'] .tab").length +") ") + title; } + } else { + t.childNodes[3].title = title; + t.childNodes[3].childNodes[1].textContent = title; } } } diff --git a/scripts/tabs.js b/scripts/tabs.js index 4f790e1..b80df43 100644 --- a/scripts/tabs.js +++ b/scripts/tabs.js @@ -10,283 +10,553 @@ async function UpdateData() { schedule_update_data = 1; } if (schedule_update_data > 0) { - $(".pin").each(function() { - chrome.runtime.sendMessage({ - command: "update_tab", - tabId: parseInt(this.id), - tab: { - parent: "pin_list", - index: $(this).index(), - expand: "n" - } - }); + if (opt.debug) console.log("function: update tabs"); + let pins_data = []; + document.querySelectorAll(".pin").forEach(function(pin){ + pins_data.push({id: pin.id, index: Array.from(pin.parentNode.children).indexOf(pin)}); }); - $(".tab").each(function() { - chrome.runtime.sendMessage({ - command: "update_tab", - tabId: parseInt(this.id), - tab: { - parent: $(this).parent().parent()[0].id, - index: $(this).index(), - expand: ($(this).is(".n") ? "n" : ($(this).is(".c") ? "c" : "o")) - } - }); + let tabs_data = []; + document.querySelectorAll(".tab").forEach(function(tab){ + tabs_data.push({id: tab.id, parent: tab.parentNode.parentNode.id, index: Array.from(tab.parentNode.children).indexOf(tab), expand: (tab.classList.contains("c") ? "c" : (tab.classList.contains("o") ? "o" : ""))}); }); + chrome.runtime.sendMessage({command: "update_all_tabs", pins: pins_data, tabs: tabs_data}); schedule_update_data--; } }, 1000); } + function RearrangeBrowserTabs() { setInterval(function() { if (schedule_rearrange_tabs > 0) { schedule_rearrange_tabs--; - let tabIds = $(".pin, .tab").map(function(){return parseInt(this.id);}).toArray(); + let tabIds = Array.prototype.map.call(document.querySelectorAll(".pin, .tab"), function(s){ + return parseInt(s.id); + }); RearrangeBrowserTabsLoop(tabIds, tabIds.length-1); } }, 1000); } + async function RearrangeBrowserTabsLoop(tabIds, tabIndex) { if (tabIndex >= 0 && schedule_rearrange_tabs == 0){ - chrome.tabs.get(tabIds[tabIndex], function(tab1) { - if (tabIndex != tab1.index) { + chrome.tabs.get(tabIds[tabIndex], function(tab) { + if (tab && tabIndex != tab.index) { chrome.tabs.move(tabIds[tabIndex], {index: tabIndex}); } RearrangeBrowserTabsLoop( tabIds, (tabIndex-1) ); }); } } + function RearrangeTreeTabs(tabs, bgtabs, first_loop) { tabs.forEach(function(Tab) { - if (bgtabs[Tab.id] && $("#"+Tab.id)[0] && $("#"+Tab.id).parent().children().eq(bgtabs[Tab.id].index)[0]) { - if ($("#"+Tab.id).index() > bgtabs[Tab.id].index) { - $("#"+Tab.id).insertBefore($("#"+Tab.id).parent().children().eq(bgtabs[Tab.id].index)); + let t = document.getElementById(Tab.id); + if (bgtabs[Tab.id] && t != null && t.parentNode.childNodes[bgtabs[Tab.id].index]) { + let tInd = Array.from(t.parentNode.children).indexOf(t); + if (tInd > bgtabs[Tab.id].index) { + t.parentNode.childNodes[bgtabs[Tab.id].index].parentNode.insertBefore(t, t.parentNode.childNodes[bgtabs[Tab.id].index]); } else { - $("#"+Tab.id).insertAfter($("#"+Tab.id).parent().children().eq(bgtabs[Tab.id].index)); + if (t.parentNode.childNodes[bgtabs[Tab.id].index].nextSibling != null) { + t.parentNode.childNodes[bgtabs[Tab.id].index].parentNode.insertBefore(t, t.parentNode.childNodes[bgtabs[Tab.id].index].nextSibling); + } else { + t.parentNode.childNodes[bgtabs[Tab.id].index].parentNode.appendChild(t); + } + } + let newtInd = Array.from(t.parentNode.children).indexOf(t); + if (bgtabs[Tab.id] && newtInd != bgtabs[Tab.id].index && first_loop) { + RearrangeTreeTabs(tabs, bgtabs, false); } - } - if (bgtabs[Tab.id] && $("#"+Tab.id).index() != bgtabs[Tab.id].index && first_loop) { - RearrangeTreeTabs(tabs, bgtabs, false); } }); } -// param - tuple object with paramenters: param.tab - tab object, param.ParentId - Parent tabId, param.InsertAfterId - insert tab after this tabId (on same level), -// param.Append - if true Appends tab at the end of tree if false or prepends -function AppendTab(param) { - if ($("#"+param.tab.id).length > 0) { - GetFaviconAndTitle(param.tab.id, param.addCounter); + +function AppendTab(tab, ParentId, InsertBeforeId, InsertAfterId, Append, Index, SetEvents, AdditionalClass, SkipSetActive, Scroll, addCounter) { + if (document.getElementById(tab.id) != null) { + GetFaviconAndTitle(tab.id, addCounter); return; } - var ClassList = param.tab.pinned ? "pin" : "tab n"; - if (param.tab.discarded) { + var ClassList = tab.pinned ? "pin" : "tab"; + if (tab.discarded) { ClassList = ClassList + " discarded"; } - if (param.AdditionalClass) { - ClassList = ClassList +" "+ param.AdditionalClass; + if (AdditionalClass != false) { + ClassList = ClassList +" "+ AdditionalClass; } - var tb = document.createElement("div"); tb.className = ClassList; tb.id = param.tab.id; // TAB - var dc = document.createElement("div"); dc.className = "drop_target drag_enter_center"; dc.id = "dc"+param.tab.id; tb.appendChild(dc); // DROP TARGET CENTER - var dt = document.createElement("div"); dt.className = "drop_target drag_entered_top"; dt.id = "du"+param.tab.id; tb.appendChild(dt); // DROP TARGET TOP - var db = document.createElement("div"); db.className = "drop_target drag_entered_bottom"; db.id = "dd"+param.tab.id; tb.appendChild(db); // DROP TARGET BOTTOM - var th = document.createElement("div"); th.className = opt.always_show_close ? "tab_header close_show" : "tab_header"; th.id = "tab_header"+param.tab.id; th.draggable = true; tb.appendChild(th); // HEADER - var ex = document.createElement("div"); ex.className = "expand"; ex.id = "exp"+param.tab.id; th.appendChild(ex); // EXPAND ARROW - var tt = document.createElement("div"); tt.className = "tab_title"; tt.id = "tab_title"+param.tab.id; th.appendChild(tt); // TITLE - // var tc = document.createElement("div"); tc.className = "tab_counter"; tc.id = "tab_counter"+param.tab.id; th.appendChild(tc); // TABS COUNTER + var tb = document.createElement("div"); tb.className = ClassList; tb.id = tab.id; // TAB + var dc = document.createElement("div"); dc.className = "drop_target drag_enter_center"; dc.id = "dc"+tab.id; tb.appendChild(dc); // DROP TARGET CENTER + var du = document.createElement("div"); du.className = "drop_target drag_entered_top"; du.id = "du"+tab.id; tb.appendChild(du); // DROP TARGET TOP + var dd = document.createElement("div"); dd.className = "drop_target drag_entered_bottom"; dd.id = "dd"+tab.id; tb.appendChild(dd); // DROP TARGET BOTTOM + var th = document.createElement("div"); th.className = (opt.always_show_close && !opt.never_show_close) ? "tab_header close_show" : "tab_header"; th.id = "tab_header"+tab.id; if (SetEvents) {th.draggable = true;} tb.appendChild(th); // HEADER + var ex = document.createElement("div"); ex.className = "expand"; ex.id = "exp"+tab.id; th.appendChild(ex); // EXPAND ARROW + var tt = document.createElement("div"); tt.className = "tab_title"; tt.id = "tab_title"+tab.id; th.appendChild(tt); // TITLE if (!opt.never_show_close) { - var cl = document.createElement("div"); cl.className = "close"; cl.id = "close"+param.tab.id; th.appendChild(cl); // CLOSE BUTTON - var ci = document.createElement("div"); ci.className = "close_img"; ci.id = "close_img"+param.tab.id; cl.appendChild(ci); + var cl = document.createElement("div"); cl.className = "close"; cl.id = "close"+tab.id; th.appendChild(cl); // CLOSE BUTTON + var ci = document.createElement("div"); ci.className = "close_img"; ci.id = "close_img"+tab.id; cl.appendChild(ci); } - var mi = document.createElement("div"); mi.className = "tab_mediaicon"; mi.id = "tab_mediaicon"+param.tab.id; th.appendChild(mi); - var ch = document.createElement("div"); ch.className = "children"; ch.id = "ch"+param.tab.id; tb.appendChild(ch); - if (param.tab.pinned) { - param.ParentId = "pin_list"; - } else { - if (param.ParentId == undefined || $("#"+param.ParentId).is(".pin, #pin_list") || $("#"+param.ParentId).length == 0) { - param.ParentId = "ch"+active_group; - } else { - if ($("#ch"+param.ParentId).children().length == 0) { - $("#"+param.ParentId).addClass("o").removeClass("n").removeClass("c"); + var mi = document.createElement("div"); mi.className = "tab_mediaicon"; mi.id = "tab_mediaicon"+tab.id; th.appendChild(mi); + var ct = document.createElement("div"); ct.className = "children_tabs"; ct.id = "ct"+tab.id; tb.appendChild(ct); + + if (SetEvents) { + ct.onmousedown = function(event) { + if (event.target == this) { + if (event.which == 1) { + DeselectFolders(); + DeselectTabs(); + } + if (event.which == 2 && event.target == this) { + event.stopImmediatePropagation(); + ActionClickGroup(this.parentNode, opt.midclick_group); + } + if (event.which == 3) { + ShowFGlobalMenu(event); + } + } + } + ct.ondblclick = function(event) { + if (event.target == this) { + ActionClickGroup(this.parentNode, opt.dbclick_group); + } + } + ex.onmousedown = function(event) { + if (document.getElementById("main_menu").style.top != "-1000px") { + HideMenus(); + } + if (event.which == 1 && !event.shiftKey && !event.ctrlKey) { + EventExpandBox(this.parentNode.parentNode); + } + } + ex.onmouseenter = function(event) { + this.classList.add("hover"); + } + ex.onmouseleave = function(event) { + this.classList.remove("hover"); + } + + if (!opt.never_show_close) { + cl.onmousedown = function(event) { + event.stopImmediatePropagation(); + if (event.which != 3) { + CloseTabs([parseInt(this.parentNode.parentNode.id)]); + } + } + cl.onmouseenter = function(event) { + this.classList.add("close_hover"); + } + cl.onmouseleave = function(event) { + this.classList.remove("close_hover"); + } + } + tb.ondragenter = function(event) { + this.childNodes[1].style.zIndex = 99999; + } + + + th.onclick = function(event) { + event.stopImmediatePropagation(); + if (document.getElementById("main_menu").style.top != "-1000px") { + HideMenus(); + } else { + if (event.which == 1 && !event.shiftKey && !event.ctrlKey && (event.target.classList.contains("tab_title") || event.target.classList.contains("tab_header"))) { + DeselectTabs(); + // SetActiveTab(this.parentNode.id); + chrome.tabs.update(parseInt(this.parentNode.id), { active: true }); + } + } + } + th.ondblclick = function(event) { + if (event.target.classList && (event.target.classList.contains("tab_title") || event.target.classList.contains("tab_header"))) { + ActionClickTab(this.parentNode, opt.dbclick_tab); + } + } + + th.onmousedown = function(event) { + event.stopImmediatePropagation(); + if (event.which == 1) { + // SELECT TAB/PIN + EventSelectTab(event, this.parentNode); + } + if (event.which == 2) { + event.preventDefault(); + ActionClickTab(this.parentNode, opt.midclick_tab); + } + if (event.which == 3) { + ShowTabMenu(this.parentNode, event); + } + } + + th.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"); + } + } + th.onmouseleave = function(event) { + this.classList.remove("tab_header_hover"); + if (opt.never_show_close == false && opt.always_show_close == false) { + this.classList.remove("close_show"); + } + } + th.ondragstart = function(event) { // DRAG START + event.stopPropagation(); + event.dataTransfer.setDragImage(document.getElementById("DragImage"), 0, 0); + event.dataTransfer.setData("text", ""); + // event.dataTransfer.setData("text/plain", ""); + // event.dataTransfer.setData("TTSourceWindowId", CurrentWindowId); + + CleanUpDragClasses(); + EmptyDragAndDrop(); + + DropTargetsFront(this, true, false); + + if (this.parentNode.classList.contains("selected_tab") == false) { + document.querySelectorAll(".selected_tab").forEach(function(s){ + s.classList.add("selected_frozen"); + s.classList.remove("selected_tab"); + s.classList.remove("selected_last"); + }); + this.parentNode.classList.add("selected_temporarly"); + this.parentNode.classList.add("selected_tab"); + } else { + document.querySelectorAll(".group:not(#"+active_group+") .selected_tab").forEach(function(s){ + s.classList.add("selected_frozen"); + s.classList.remove("selected_tab"); + s.classList.remove("selected_last"); + }); + } + let Tabs = GetSelectedTabs(); + + document.querySelectorAll("[id='"+this.parentNode.id+"'], [id='"+this.parentNode.id+"'] .folder, [id='"+this.parentNode.id+"'] .tab").forEach(function(s){ + s.classList.add("dragged_tree"); + }); + document.querySelectorAll(".selected_tab, .selected_tab .tab, .selected_folder, .selected_folder .folder").forEach(function(s){ + s.classList.add("dragged_selected"); + }); + + if (opt.max_tree_drag_drop) { + document.querySelectorAll(".dragged_tree .tab").forEach(function(s){ + let parents = GetParentsByClass(s.parentNode, "dragged_tree"); + if (parents.length > DragAndDrop.Depth) { + DragAndDrop.Depth = parents.length; + } + }); + } else { + DragAndDrop.Depth = -1; + } + + DragAndDrop.TabsIds = Object.assign([], Tabs.TabsIds); + DragAndDrop.TabsIdsParents = Object.assign([], Tabs.TabsIdsParents); + DragAndDrop.TabsIdsSelected = Object.assign([], Tabs.TabsIdsSelected); + DragAndDrop.DragNodeClass = "tab"; + DragAndDrop.ComesFromWindowId = CurrentWindowId; + + chrome.runtime.sendMessage({ + command: "drag_drop", + DragNodeClass: DragAndDrop.DragNodeClass, + TabsIds: DragAndDrop.TabsIds, + TabsIdsParents: DragAndDrop.TabsIdsParents, + TabsIdsSelected: DragAndDrop.TabsIdsSelected, + ComesFromWindowId: CurrentWindowId, + Depth: DragAndDrop.Depth, + Folders: DragAndDrop.Folders, + FoldersSelected: DragAndDrop.FoldersSelected + }); + } + + th.ondragenter = function(event) { + this.classList.remove("tab_header_hover"); + } + + dc.ondragenter = function(event) { + DragAndDrop.timeout = false; + setTimeout(function() { + DragAndDrop.timeout = true; + }, 1000); + if (DragAndDrop.DragNodeClass == "tab") { + HighlightDragEnter(this, 0, "tab"); + } + } + + du.ondragenter = function(event) { + if (DragAndDrop.DragNodeClass == "tab") { + HighlightDragEnter(this, 1, "tab"); + } + } + + dd.ondragenter = function(event) { + if (DragAndDrop.DragNodeClass == "tab") { + HighlightDragEnter(this, 1, "tab"); + } + } + + mi.onmousedown = function(event) { + event.stopImmediatePropagation(); + if (event.which == 1 && (this.parentNode.parentNode.classList.contains("audible") || this.parentNode.parentNode.classList.contains("muted")) ) { + chrome.tabs.get(parseInt(this.parentNode.parentNode.id), function(tab) { + if (tab) { + chrome.tabs.update(tab.id, {muted:!tab.mutedInfo.muted}); + } + }); } - param.ParentId = "ch"+param.ParentId; } } - if (param.Append) { - $("#"+param.ParentId).append(tb); + + let parent; + if (tab.pinned) { + parent = document.getElementById("pin_list"); + } else { + if (ParentId == false || ParentId == undefined || document.getElementById(ParentId) == null || document.querySelector(".pin[id='"+ParentId+"']") != null || ParentId == "pin_list") { + parent = document.getElementById("ct"+active_group); + } else { + parent = document.getElementById("ct"+ParentId); + if (parent.children.length == 0) { + parent.parentNode.classList.add("o"); + parent.parentNode.classList.remove("c"); + } + } + } + if (Append && parent) { + parent.appendChild(tb); } - if (!param.Append) { - $("#"+param.ParentId).prepend(tb); + if (!Append && parent) { + parent.prepend(tb); } - if (param.InsertBeforeId != undefined && $("#"+param.InsertBeforeId)[0]) { - if ((param.tab.pinned && $("#"+param.InsertBeforeId).is(".pin")) || (!param.tab.pinned && $("#"+param.InsertBeforeId).is(".tab"))) { - $("#"+param.tab.id).insertBefore($("#"+param.InsertBeforeId)); + + if (InsertBeforeId) { + let Before = document.getElementById(InsertBeforeId); + if (Before != null) { + if ((tab.pinned && Before.classList.contains("pin")) || (tab.pinned == false && Before.classList.contains("tab"))) { + Before.parentNode.insertBefore(tb, Before); + } } } - if (param.InsertAfterId != undefined && $("#"+param.InsertAfterId)[0]) { - if ((param.tab.pinned && $("#"+param.InsertAfterId).is(".pin")) || (!param.tab.pinned && $("#"+param.InsertAfterId).is(".tab"))) { - $("#"+param.tab.id).insertAfter($("#"+param.InsertAfterId)); + if (InsertAfterId) { + let After = document.getElementById(InsertAfterId); + if (After != null) { + if ((tab.pinned && After.classList.contains("pin")) || (tab.pinned == false && After.classList.contains("tab"))) { + if (After.nextSibling != null) { + After.parentNode.insertBefore(tb, After.nextSibling); + } else { + After.parentNode.appendChild(tb); + } + } } } - GetFaviconAndTitle(param.tab.id, param.addCounter); - RefreshMediaIcon(param.tab.id); - if (param.tab.active && param.SkipSetActive == undefined) { - SetActiveTab(param.tab.id); + if (Index) { + if (tb.parentNode.childNodes.length >= Index) { + tb.parentNode.insertBefore(tb, tb.parentNode.childNodes[Index]); + } else { + tb.parentNode.appendChild(tb); + } } - if (param.Scroll) { - ScrollToTab(param.tab.id); + GetFaviconAndTitle(tab.id, addCounter); + RefreshMediaIcon(tab.id); + if (tab.active && SkipSetActive == false) { + SetActiveTab(tab.id); } -} -function RemoveTabFromList(tabId) { - if ($("#"+tabId)[0]) { - $("#"+tabId).remove(); + if (Scroll) { + ScrollToTab(tab.id); } } -function SetTabClass(param) { // param - tuple object with paramenters: param.pin - true for pinned, param.id - tabId - if (param.pin) { - $("#pin_list").append($("#"+param.id)); - if ($("#ch"+param.id).children().length > 0) { // flatten out children - $($("#"+param.id).children().find(".pin, .tab").get().reverse()).each(function() { - $(this).removeClass("tab").removeClass("n").removeClass("o").removeClass("c").addClass("pin"); - $(this).insertAfter($("#"+param.id)); - chrome.tabs.update(parseInt(this.id), {pinned: true}); - }); - } - $("#"+param.id).removeClass("tab").removeClass("n").removeClass("o").removeClass("c").addClass("pin"); - } else { - $("#ch"+active_group).prepend($("#"+param.id)); - $("#"+param.id).removeClass("pin").removeClass("attention").addClass("tab"); - RefreshExpandStates(); - } - chrome.tabs.update(parseInt(param.id), {pinned: param.pin}); - RefreshGUI(); -} -function SetActiveTab(tabId) { - if ($("#"+tabId).length > 0) { - if ($("#"+tabId).is(".tab")) { - SetActiveTabInGroup($("#"+tabId).parents(".group")[0].id, tabId); - } - $(".selected_folder").removeClass("selected_folder"); - $(".pin, #"+active_group+" .tab").removeClass("active_tab").removeClass("selected_tab").removeClass("selected_frozen").removeClass("selected_temporarly").removeClass("tab_header_hover"); - $(".highlighted_drop_target").removeClass("highlighted_drop_target"); - $("#"+tabId).removeClass("attention").addClass("active_tab"); - ScrollToTab(tabId); +function RemoveTabFromList(tabId) { + let tab = document.getElementById(tabId); + if (tab != null) { + tab.parentNode.removeChild(tab); } } -function ScrollToTab(tabId) { - if ($("#"+tabId)[0]) { - if ($("#"+tabId).is(".pin")) { - if ($("#"+tabId).position().left+$("#"+tabId).outerWidth() > $("#pin_list").innerWidth()) { - $("#pin_list").scrollLeft($("#pin_list").scrollLeft()+$("#"+tabId).position().left+$("#"+tabId).outerWidth()-$("#pin_list").innerWidth()); - } else { - if ($("#"+tabId).position().left < 0) { - $("#pin_list").scrollLeft($("#pin_list").scrollLeft()+$("#"+tabId).position().left); - } + +function SetTabClass(tabId, pin) { + let PinList = document.getElementById("pin_list"); + let GroupList = document.getElementById("ct"+active_group); + let Tab = document.getElementById(tabId); + if (Tab != null) { + if (pin) { + if (Tab.parentNode.id != "pin_list") { + document.getElementById("pin_list").appendChild(Tab); } - } - if ($("#"+tabId).is(".tab")) { - if ($("#"+active_group+" #"+tabId)[0]) { - if ($("#"+tabId).is(":not(:visible)")) { - $("#"+tabId).parents(".folder, .tab").removeClass("c").addClass("o"); - } - if ($("#"+tabId).offset().top - $("#"+active_group).offset().top < 0) { - $("#"+active_group).scrollTop($("#"+active_group).scrollTop() + $("#"+tabId).offset().top - $("#"+active_group).offset().top); - } else { - if ($("#"+tabId).offset().top - $("#"+active_group).offset().top > $("#"+active_group).innerHeight() - $(".tab_header").outerHeight()) { - $("#"+active_group).scrollTop($("#"+active_group).scrollTop() + $("#"+tabId).offset().top - $("#"+active_group).offset().top - $("#"+active_group).innerHeight() + $(".tab_header").outerHeight() + 4); + Tab.classList.remove("tab"); + Tab.classList.remove("o"); + Tab.classList.remove("c"); + Tab.classList.add("pin"); + if (document.getElementById("ct"+tabId).childNodes.length > 0) { // flatten out children + let tabs = document.querySelectorAll("#ct"+tabId+" .pin, #ct"+tabId+" .tab"); + for (let i = tabs.length-1; i >= 0; i--) { + tabs[i].remove("tab"); + tabs[i].remove("o"); + tabs[i].remove("c"); + tabs[i].classList.add("pin"); + if(Tab.nextSibling != null) { + PinList.insertBefore(tabs[i], Tab.nextSibling); + } else { + PinList.appendChild(tabs[i]); } + chrome.tabs.update(parseInt(tabs[i].id), {pinned: true}); + } + } + + } else { + if (GroupList.childNodes.length > 0) { // flatten out children + GroupList.insertBefore(Tab, GroupList.childNodes[0]); + } else { + GroupList.appendChild(Tab); + } + Tab.classList.remove("pin"); + Tab.classList.remove("attention"); + Tab.classList.add("tab"); + RefreshExpandStates(); + } + chrome.tabs.update(parseInt(tabId), {pinned: pin}); + RefreshGUI(); + } +} + +function SetActiveTab(tabId) { + let Tab = document.getElementById(tabId); + if (Tab != null) { + document.querySelectorAll(".selected_folder").forEach(function(s){ + s.classList.remove("selected_folder"); + }); + document.querySelectorAll(".pin, #"+active_group+" .tab").forEach(function(s){ + s.classList.remove("active_tab"); + s.classList.remove("selected_tab"); + s.classList.remove("selected_last"); + s.classList.remove("selected_frozen"); + s.classList.remove("selected_temporarly"); + s.classList.remove("tab_header_hover"); + }); + document.querySelectorAll(".highlighted_drop_target").forEach(function(s){ + s.classList.remove("highlighted_drop_target"); + }); + Tab.classList.remove("attention"); + Tab.classList.add("active_tab"); + ScrollToTab(tabId); + if (Tab.classList.contains("tab")) { + SetActiveTabInGroup(active_group, tabId); + } + } +} + +function ScrollToTab(tabId) { + let Tab = document.getElementById(tabId); + if (Tab != null) { + if (Tab.classList.contains("pin")) { + if (Tab.getBoundingClientRect().left - document.getElementById("pin_list").getBoundingClientRect().left < 0) { + document.getElementById("pin_list").scrollLeft = document.getElementById("pin_list").scrollLeft + Tab.getBoundingClientRect().left - document.getElementById("pin_list").getBoundingClientRect().left - 2; + } else { + if (Tab.getBoundingClientRect().left - document.getElementById("pin_list").getBoundingClientRect().left > document.getElementById(active_group).getBoundingClientRect().width - document.querySelector(".tab_header").getBoundingClientRect().width) { + document.getElementById("pin_list").scrollLeft = document.getElementById("pin_list").scrollLeft + Tab.getBoundingClientRect().left - document.getElementById("pin_list").getBoundingClientRect().left - document.getElementById("pin_list").getBoundingClientRect().width + document.querySelector(".tab_header").getBoundingClientRect().width + 2; + } + } + } + if (Tab.classList.contains("tab") && document.querySelector("#"+active_group+" [id='"+tabId+"']") != null) { + let Parents = GetParentsByClass(Tab, "c"); + if (Parents.length > 0) { + Parents.forEach(function(s){ + s.classList.remove("c"); + s.classList.add("o"); + }); + } + if (Tab.getBoundingClientRect().top - document.getElementById(active_group).getBoundingClientRect().top < 0) { + document.getElementById(active_group).scrollTop = document.getElementById(active_group).scrollTop + Tab.getBoundingClientRect().top - document.getElementById(active_group).getBoundingClientRect().top - 2; + } else { + if (Tab.getBoundingClientRect().top - document.getElementById(active_group).getBoundingClientRect().top > document.getElementById(active_group).getBoundingClientRect().height - document.querySelector(".tab_header").getBoundingClientRect().height) { + document.getElementById(active_group).scrollTop = document.getElementById(active_group).scrollTop + Tab.getBoundingClientRect().top - document.getElementById(active_group).getBoundingClientRect().top - document.getElementById(active_group).getBoundingClientRect().height + document.querySelector(".tab_header").getBoundingClientRect().height + 10; } } } } } -function DetachTabs(tabsIds, Folders) { + +function Detach(tabsIds, Folders) { chrome.windows.get(CurrentWindowId, {populate : true}, function(window) { - if (window.tabs.length == 1 || tabsIds.length == 0 || tabsIds.length == window.tabs.length) { + if (window.tabs.length == 1 || tabsIds.length == 0) { return; } - chrome.windows.create({state:window.state}, function(new_window) { + if (tabsIds.length == window.tabs.length) { + if (opt.debug) console.log("You are trying to detach all tabs! Skipping!"); + return; + } + chrome.windows.create({tabId: tabsIds[0], state:window.state}, function(new_window) { let Indexes = []; let Parents = []; let Expands = []; - let NewIds = []; + let NewIds = []; // MOZILLA BUG 1398272 let NewTabs = []; - tabsIds.forEach(function(tabId) { - Indexes.push($("#"+tabId).index()); - Parents.push($("#"+tabId).parent().parent()[0].id); - Expands.push($("#"+tabId).is(".n") ? "n" : ($("#"+tabId).is(".c") ? "c" : "o")); - }); let Ind = 0; + tabsIds.forEach(function(tabId) { + let tab = document.getElementById(tabId); + NewIds.push(tabId); // MOZILLA BUG 1398272 + Indexes.push(Array.from(tab.parentNode.children).indexOf(tab)); + Parents.push(tab.parentNode.parentNode.id); + Expands.push( (tab.classList.contains("c") ? "c" : (tab.classList.contains("o") ? "o" : "")) ); + }); tabsIds.forEach(function(tabId) { chrome.tabs.move(tabId, {windowId: new_window.id, index:-1}, function(MovedTab) { - NewIds.push(MovedTab[0].id); - if (browserId == "F") { // AGAIN BUG 1398272 - MOZILLA! - NewTabs.push({id: NewIds[Ind], index: Indexes[Ind], parent: ((tabsIds.indexOf(parseInt(Parents[Ind])) != -1) ? NewIds[tabsIds.indexOf(parseInt(Parents[Ind]))] : Parents[Ind]), expand: Expands[Ind]}); - } else { - NewTabs.push({id: NewIds[Ind], index: Indexes[Ind], parent: Parents[Ind], expand: Expands[Ind]}); - } + if (browserId == "F") { // MOZILLA BUG 1398272 + if (Ind == 0) { // MOZILLA BUG 1398272 + NewIds[Ind] = new_window.tabs[0].id; // MOZILLA BUG 1398272 + } else { // MOZILLA BUG 1398272 + NewIds[Ind] = MovedTab[0].id; // MOZILLA BUG 1398272 + } // MOZILLA BUG 1398272 + NewTabs.push({id: NewIds[Ind], index: Indexes[Ind], parent: ((tabsIds.indexOf(parseInt(Parents[Ind])) != -1) ? NewIds[tabsIds.indexOf(parseInt(Parents[Ind]))] : Parents[Ind]), expand: Expands[Ind]}); // MOZILLA BUG 1398272 + } else { // MOZILLA BUG 1398272 + NewTabs.push({id: tabsIds[Ind], index: Indexes[Ind], parent: Parents[Ind], expand: Expands[Ind]}); // PUSH TAB FROM INDEX + } // MOZILLA BUG 1398272 Ind++; + if (Ind >= Parents.length-1) { + // chrome.tabs.remove(new_window.tabs[0].id, null); + let Confirmations = 0; + let GiveUpLimit = 600; + if (opt.debug) console.log("Detach - Remote Append and Update Loop, waiting for confirmations after attach tabs"); + var Append = setInterval(function() { + chrome.windows.get(new_window.id, function(confirm_new_window) { + chrome.runtime.sendMessage({command: "remote_update", groups: {}, folders: Folders, tabs: NewTabs, windowId: new_window.id}, function(response) { + if (response) { + Confirmations++; + } + }); + GiveUpLimit--; + if (opt.debug) console.log("Detach -> Attach in new window confirmed: "+Confirmations+" times. If sidebar is not open in new window this loop will give up in: "+GiveUpLimit+" seconds"); + if (Confirmations > 2 || GiveUpLimit < 0 || confirm_new_window == undefined) { + clearInterval(Append); + } + }); + }, 1000); + if (Folders && Object.keys(Folders).length > 0) { + for (var folder in Folders) { + RemoveFolder(Folders[folder].id); + } + } + } }); }); - chrome.tabs.remove(new_window.tabs[0].id, null); - let Loop = 0; - var Append = setInterval(function() { - chrome.runtime.sendMessage({command: "remote_update", groups: {}, folders: Folders, tabs: NewTabs, windowId: new_window.id}, function(response) { - log("Detach - Remote Append and Update Loop, giving half second to attach each tab"); - }); - Loop++; - if (Loop > tabsIds.length) { - clearInterval(Append); - } - }, 500); - - if (Object.keys(Folders).length > 0) { - for (var folder in Folders) { - RemoveFolder(Folders[folder].id); - } - } - - }); - }); -} -function FindTab(input) { // find and select tabs - $(".filtered").removeClass("filtered").removeClass("selected_tab"); - $(".highlighted_search").removeClass("highlighted_search"); - if (input.length == 0) { - $("#filter_box")[0].value = ""; - $("#button_filter_clear").css({"opacity": "0"}).attr("title", ""); - return; - } else { - $("#button_filter_clear").css({"opacity": "1"}); - $("#button_filter_clear").attr("title", caption_clear_filter); - } - SearchIndex = 0; - chrome.tabs.query({windowId: CurrentWindowId, pinned: false}, function(tabs) { - tabs.forEach(function(Tab) { - if ($("#button_filter_type").is(".url") && Tab.url.toLowerCase().match(input.toLowerCase())) { - $("#"+Tab.id).addClass("filtered").addClass("selected_tab"); - } - if ($("#button_filter_type").is(".title") && Tab.title.toLowerCase().match(input.toLowerCase())) { - $("#"+Tab.id).addClass("filtered").addClass("selected_tab"); - } }); }); } + function CloseTabs(tabsIds) { - if ($("#"+active_group+" .active_tab")[0] && tabsIds.indexOf(parseInt($("#"+active_group+" .active_tab")[0].id)) != -1) { - ActionBeforeTabsClose(); + let activeTab = document.querySelector(".pin.active_tab, #"+active_group+" .tab.active_tab"); + if (activeTab != null && tabsIds.indexOf(parseInt(activeTab.id)) != -1) { + SwitchActiveTabBeforeClose(active_group); } tabsIds.forEach(function(tabId) { - if ($("#"+tabId).is(".pin") && opt.allow_pin_close) { - $("#"+tabId).remove(); + let tab = document.getElementById(tabId); + if (tab.classList.contains("pin") && opt.allow_pin_close) { + tab.parentNode.removeChild(tab); chrome.tabs.update(tabId, {pinned: false}); } + if (tabId == tabsIds[tabsIds.length-1]) { + setTimeout(function() { + chrome.tabs.remove(tabsIds, null); + }, 10); + } }); - setTimeout(function() { - chrome.tabs.remove(tabsIds, null); - }, 50); } + function DiscardTabs(tabsIds) { var delay = 100; - if ($("#"+tabsIds[0]).is(".discarded")) { + let tabNode = document.getElementById(tabsIds[0]); + if (tabNode == null || tabNode.classList.contains("discarded") || tabNode.classList.contains("active_tab")) { delay = 5; } else { chrome.tabs.discard(tabsIds[0]); @@ -298,40 +568,40 @@ function DiscardTabs(tabsIds) { }, delay); } } -function ActionBeforeTabsClose() { - log("function: ActionBeforeTabsClose"); - if ($("#"+active_group+" .tab").length == 1) { - log("there is only one tab"); + +function SwitchActiveTabBeforeClose(ActiveGroupId) { + if (opt.debug) console.log("function: SwitchActiveTabBeforeClose"); + let activeGroup = document.getElementById(ActiveGroupId); + if (document.querySelectorAll("#"+ActiveGroupId+" .tab").length <= 1 && document.querySelector(".pin.active_tab") == null) { if (opt.after_closing_active_tab == "above" || opt.after_closing_active_tab == "above_seek_in_parent") { - log("activate group above"); - if ($("#"+active_group).prev(".group")[0]) { - SetActiveGroup(($("#"+active_group).prev(".group")[0].id), true, true); - } else { - if ($("#"+active_group).next(".group")[0]) { - SetActiveGroup(($("#"+active_group).next(".group")[0].id), true, true); + if (activeGroup.previousSibling != null) { + if (document.querySelectorAll("#"+activeGroup.previousSibling.id+" .tab").length > 0) { + SetActiveGroup(activeGroup.previousSibling.id, true, true); } else { - SetActiveGroup("tab_list", true, true); + SwitchActiveTabBeforeClose(activeGroup.previousSibling.id); + return; } + } else { + SetActiveGroup("tab_list", true, true); } } else { - log("activate group below"); - if ($("#"+active_group).next(".group")[0]) { - SetActiveGroup(($("#"+active_group).next(".group")[0].id), true, true); - } else { - if ($("#"+active_group).prev(".group")[0]) { - SetActiveGroup(($("#"+active_group).prev(".group")[0].id), true, true); + if (activeGroup.nextSibling != null) { + if (document.querySelectorAll("#"+activeGroup.nextSibling.id+" .tab").length > 0) { + SetActiveGroup(activeGroup.nextSibling.id, true, true); } else { - SetActiveGroup("tab_list", true, true); + SwitchActiveTabBeforeClose(activeGroup.nextSibling.id); + return; } + } else { + SetActiveGroup("tab_list", true, true); } } } else { - log("there are more tabs"); if (opt.after_closing_active_tab == "above") { - ActivatePrevTab(); + ActivatePrevTab(true); } if (opt.after_closing_active_tab == "below") { - ActivateNextTab(); + ActivateNextTab(true); } if (opt.after_closing_active_tab == "above_seek_in_parent") { ActivatePrevTabBeforeClose(); @@ -341,249 +611,314 @@ function ActionBeforeTabsClose() { } } } + function ActivateNextTabBeforeClose() { - log("function: ActivateNextTabBeforeClose"); - if ($(".pin.active_tab:visible")[0]) { - if ($(".pin.active_tab").next(".pin")[0]) { - chrome.tabs.update(parseInt($(".pin.active_tab").next(".pin")[0].id), { active: true }); + let activePin = document.querySelector(".pin.active_tab"); + if (activePin != null) { + if (activePin.nextSibling != null) { + chrome.tabs.update(parseInt(activePin.nextSibling.id), { active: true }); } else { - if ($(".pin.active_tab").prev(".pin")[0]) { - chrome.tabs.update(parseInt($(".pin.active_tab").prev(".pin")[0].id), { active: true }); + if (activePin.previousSibling != null) { + chrome.tabs.update(parseInt(activePin.previousSibling.id), { active: true }); } } } - if ($("#"+active_group+" .tab.active_tab")[0] && $("#"+active_group+" .tab").length > 1) { - if ($("#"+active_group+" .tab.active_tab").children().last().children(".tab")[0]) { - chrome.tabs.update(parseInt($("#"+active_group+" .tab.active_tab").children().last().children(".tab")[0].id), { active: true }); + let activeTab = document.querySelector("#"+active_group+" .tab.active_tab"); + if (activeTab != null && document.querySelectorAll("#"+active_group+" .tab").length > 1) { + if (opt.promote_children && activeTab.lastChild.firstChild != null) { + chrome.tabs.update(parseInt(activeTab.lastChild.firstChild.id), { active: true }); } else { - if ($("#"+active_group+" .tab.active_tab").next(".tab")[0]) { - chrome.tabs.update(parseInt($("#"+active_group+" .tab.active_tab").next(".tab")[0].id), { active: true }); + if (activeTab.nextSibling != null) { + chrome.tabs.update(parseInt(activeTab.nextSibling.id), { active: true }); } else { - if ($("#"+active_group+" .tab.active_tab").prev(".tab")[0]) { - chrome.tabs.update(parseInt($("#"+active_group+" .tab.active_tab").prev(".tab")[0].id), { active: true }); + if (activeTab.previousSibling != null) { + chrome.tabs.update(parseInt(activeTab.previousSibling.id), { active: true }); } else { - if ($("#"+active_group+" .tab.active_tab").parent().is(".children") && $("#"+active_group+" .tab.active_tab").parent().parent(".tab")[0]) { - chrome.tabs.update(parseInt($("#"+active_group+" .tab.active_tab").parent().parent(".tab")[0].id), { active: true }); + if (activeTab.parentNode.parentNode.classList.contains("tab")) { + chrome.tabs.update(parseInt(activeTab.parentNode.parentNode.id), { active: true }); } else { - if ($("#"+active_group+" .tab.active_tab").parents(".tab").last().next(".tab")[0]) { - chrome.tabs.update(parseInt($("#"+active_group+" .tab.active_tab").parents(".tab").last().next(".tab")[0].id), { active: true }); - } else { - ActivatePrevTab(); - } + ActivatePrevTab(); } } } } } } + function ActivatePrevTabBeforeClose() { - log("function: ActivatePrevTabBeforeClose"); - if ($(".pin.active_tab")[0]) { - log("active_tab is pin"); - if ($(".pin.active_tab").prev(".pin")[0]) { - chrome.tabs.update(parseInt($(".pin.active_tab").prev(".pin")[0].id), { active: true }); + let activePin = document.querySelector(".pin.active_tab"); + if (activePin != null) { + if (activePin.previousSibling != null) { + chrome.tabs.update(parseInt(activePin.previousSibling.id), { active: true }); } else { - if ($(".pin.active_tab").next(".pin")[0]) { - chrome.tabs.update(parseInt($(".pin.active_tab").next(".pin")[0].id), { active: true }); + if (activePin.nextSibling != null) { + chrome.tabs.update(parseInt(activePin.nextSibling.id), { active: true }); } } } - if ($("#"+active_group+" .tab.active_tab")[0] && $("#"+active_group+" .tab").length > 1) { - log("active_group tabs length is > 1"); - if ($("#"+active_group+" .tab.active_tab").children().last().children(".tab")[0]) { - log("activating first child, because active tab is root"); - chrome.tabs.update(parseInt($("#"+active_group+" .tab.active_tab").children().last().children(".tab")[0].id), { active: true }); + let activeTab = document.querySelector("#"+active_group+" .tab.active_tab"); + if (activeTab != null && document.querySelectorAll("#"+active_group+" .tab").length > 1) { + if (opt.promote_children && activeTab.lastChild.firstChild != null) { + chrome.tabs.update(parseInt(activeTab.lastChild.firstChild.id), { active: true }); } else { - if ($("#"+active_group+" .tab.active_tab").prev(".tab")[0]) { - log("activating previous tab on same level"); - chrome.tabs.update(parseInt($("#"+active_group+" .tab.active_tab").prev(".tab")[0].id), { active: true }); + if (activeTab.previousSibling != null) { + chrome.tabs.update(parseInt(activeTab.previousSibling.id), { active: true }); } else { - if ($("#"+active_group+" .tab.active_tab").next(".tab")[0]) { - log("previous tab not found, activating next one on same level"); - chrome.tabs.update(parseInt($("#"+active_group+" .tab.active_tab").next(".tab")[0].id), { active: true }); + if (activeTab.nextSibling != null) { + chrome.tabs.update(parseInt(activeTab.nextSibling.id), { active: true }); } else { - if ($("#"+active_group+" .tab.active_tab").parent().is(".children") && $(".tab.active_tab").parent().parent(".tab")[0]) { - log("previous and next tab not found, which means active tab is last on same level, activating parent"); - chrome.tabs.update(parseInt($("#"+active_group+" .tab.active_tab").parent().parent(".tab")[0].id), { active: true }); + if (activeTab.parentNode.parentNode.classList.contains("tab")) { + chrome.tabs.update(parseInt(activeTab.parentNode.parentNode.id), { active: true }); } else { - if ($("#"+active_group+" .tab.active_tab").parents(".tab").last().prev(".tab")[0]) { - log("parent tab not found, which means we are on top in hierarchy, activating previous on top level"); - chrome.tabs.update(parseInt($("#"+active_group+" .tab.active_tab").parents(".tab").last().prev(".tab")[0].id), { active: true }); - } else { - log("all attempts to find previous tab failed, lets activate next tab"); - ActivateNextTab(); - } + ActivateNextTab(); } } } } } } -function ActivateNextTab() { - log("function: ActivateNextTab"); - if ($(".pin.active_tab")[0]) { - log("active_tab is pin"); - if ($(".pin.active_tab").next(".pin")[0]) { - chrome.tabs.update(parseInt($(".pin.active_tab").next(".pin")[0].id), { active: true }); + +function ActivateNextTab(allow_reverse) { + let activePin = document.querySelector(".pin.active_tab"); + if (activePin != null) { + if (activePin.nextSibling != null) { + chrome.tabs.update(parseInt(activePin.nextSibling.id), { active: true }); } else { - if ($(".pin.active_tab").prev(".pin")[0]) { - chrome.tabs.update(parseInt($(".pin.active_tab").prev(".pin")[0].id), { active: true }); + if (activePin.previousSibling != null && allow_reverse) { + chrome.tabs.update(parseInt(activePin.previousSibling.id), { active: true }); } } } - if ($("#"+active_group+" .tab.active_tab")[0] && $("#"+active_group+" .tab").length > 1) { - if ($("#"+active_group+" .tab.active_tab").children().last().children(".tab")[0]) { - chrome.tabs.update(parseInt($("#"+active_group+" .tab.active_tab").children().last().children(".tab")[0].id), { active: true }); + let activeTab = document.querySelector("#"+active_group+" .tab.active_tab"); + if (activeTab != null && document.querySelectorAll("#"+active_group+" .tab").length > 1) { + let FirstChild = activeTab.lastChild.firstChild; + if (FirstChild != null) { + chrome.tabs.update(parseInt(FirstChild.id), { active: true }); } else { - if ($("#"+active_group+" .tab.active_tab").next(".tab")[0]) { - chrome.tabs.update(parseInt($("#"+active_group+" .tab.active_tab").next(".tab")[0].id), { active: true }); + if (activeTab.nextSibling != null) { + chrome.tabs.update(parseInt(activeTab.nextSibling.id), { active: true }); } else { - if ($("#"+active_group+" .tab.active_tab").parent().parent().next("#"+active_group+" .tab")[0]) { - chrome.tabs.update(parseInt($("#"+active_group+" .tab.active_tab").parent().parent().next(".tab")[0].id), { active: true }); + let Next = null; + while (Next == null && activeTab.parentNode != null && activeTab.parentNode.parentNode != null) { + if (activeTab.parentNode.parentNode.classList != undefined && activeTab.parentNode.parentNode.classList.contains("tab") && activeTab.parentNode.parentNode.nextSibling != null && activeTab.parentNode.parentNode.nextSibling.classList.contains("tab")) { + Next = activeTab.parentNode.parentNode.nextSibling; + } + activeTab = activeTab.parentNode.parentNode; + } + if (Next != null) { + chrome.tabs.update(parseInt(Next.id), { active: true }); } else { - if ($("#"+active_group+" .tab.active_tab").parents(".tab").last().next(".tab")[0]) { - chrome.tabs.update(parseInt($("#"+active_group+" .tab.active_tab").parents(".tab").last().next(".tab")[0].id), { active: true }); + if (allow_reverse) { + ActivatePrevTab(); } } } } } } -function ActivatePrevTab() { - log("function: ActivatePrevTab"); - if ($(".pin.active_tab")[0]) { - log("active_tab is pin"); - if ($(".pin.active_tab").prev(".pin")[0]) { - chrome.tabs.update(parseInt($(".pin.active_tab").prev(".pin")[0].id), { active: true }); + +function ActivatePrevTab(allow_reverse) { + let activePin = document.querySelector(".pin.active_tab"); + if (activePin != null) { + if (activePin.previousSibling != null) { + chrome.tabs.update(parseInt(activePin.previousSibling.id), { active: true }); } else { - if ($(".pin.active_tab").next(".pin")[0]) { - chrome.tabs.update(parseInt($(".pin.active_tab").next(".pin")[0].id), { active: true }); + if (activePin.nextSibling != null && allow_reverse) { + chrome.tabs.update(parseInt(activePin.nextSibling.id), { active: true }); } } } - if ($("#"+active_group+" .tab.active_tab")[0] && $("#"+active_group+" .tab").length > 1) { - if ($("#"+active_group+" .tab.active_tab").prev().find(".tab").length > 0) { - chrome.tabs.update(parseInt($("#"+active_group+" .tab.active_tab").prev().find(".tab").last()[0].id), { active: true }); + let activeTab = document.querySelector("#"+active_group+" .tab.active_tab"); + if (activeTab != null && document.querySelectorAll("#"+active_group+" .tab").length > 1) { + let pSchildren = activeTab.previousSibling != null ? document.querySelectorAll("#ct"+activeTab.previousSibling.id+" .tab") : null; + if (activeTab.previousSibling != null && pSchildren.length > 0) { + chrome.tabs.update(parseInt(pSchildren[pSchildren.length-1].id), { active: true }); } else { - if ($("#"+active_group+" .tab.active_tab").prev(".tab")[0]) { - chrome.tabs.update(parseInt($("#"+active_group+" .tab.active_tab").prev(".tab")[0].id), { active: true }); + if (activeTab.previousSibling != null) { + chrome.tabs.update(parseInt(activeTab.previousSibling.id), { active: true }); } else { - if ($("#"+active_group+" .tab.tab.active_tab").parent().is(".children") && $("#"+active_group+" .tab.active_tab").parent().parent(".tab")[0]) { - chrome.tabs.update(parseInt($("#"+active_group+" .tab.active_tab").parent().parent(".tab")[0].id), { active: true }); + if (activeTab.parentNode.parentNode.classList.contains("tab")) { + chrome.tabs.update(parseInt(activeTab.parentNode.parentNode.id), { active: true }); + } else { + if (allow_reverse) { + ActivateNextTab(); + } } } } } } -// ********** TABS EVENTS *************** -function SetTabEvents() { - $(document).on("dblclick", ".group, #pin_list, .tab", function(event) { // double click to create tab - if (event.button == 0 && $(event.target).is(this)) { - if (event.target.id == "pin_list") { - chrome.tabs.create({ pinned: true }); + +function DeselectTabs() { + document.querySelectorAll(".pin.selected_tab, #"+active_group+" .selected_tab").forEach(function(s){ + s.classList.remove("selected_tab"); + s.classList.remove("selected_last"); + }); +} + +function HighlightNode(Node) { + document.querySelectorAll(".highlighted_drop_target").forEach(function(s){ + s.classList.remove("highlighted_drop_target"); + }); + Node.classList.add("highlighted_drop_target"); +} + +function HighlightDragEnter(Node, addDepth, Class) { // Class == "tab" or "folder" + // PIN,TAB==>TAB OR PIN,TAB==>FOLDER + // AND AVOID ENTERING INSIDE OWN CHILDREN + if (Node.classList.contains("highlighted_drop_target") == false && Node.parentNode.classList.contains("dragged_tree") == false && Node.parentNode.classList.contains("dragged_selected") == false) { + if (opt.max_tree_depth >= 0 && DragAndDrop.Depth >= 0 && DragAndDrop.DragNodeClass == Class) { + let Parents = GetParentsByClass(Node, Class); + if ((Parents.length + DragAndDrop.Depth <= opt.max_tree_depth + addDepth) || (Node.parentNode.parentNode.parentNode.classList.contains("group") && Node.classList.contains("drag_enter_center") == false)) { + HighlightNode(Node); + } + } else { + HighlightNode(Node); + } + } +} + +function EventExpandBox(Node) { + if (Node.classList.contains("o")) { + Node.classList.remove("o"); + Node.classList.add("c"); + + if (Node.classList.contains("tab")) { + chrome.runtime.sendMessage({ command: "update_tab", tabId: parseInt(Node.id), tab: { expand: "c" } }); + } + + if (Node.classList.contains("folder")) { + SaveFolders(); + } + + } else { + if (Node.classList.contains("c")) { + if (opt.collapse_other_trees) { + let thisTreeTabs = GetParentsByClass(Node.childNodes[0], "tab"); // start from tab's first child, instead of tab, important to include clicked tab as well + let thisTreeFolders = GetParentsByClass(Node.childNodes[0], "folder"); + document.querySelectorAll("#"+active_group+" .o.tab").forEach(function(s){ + s.classList.remove("o"); + s.classList.add("c"); + chrome.runtime.sendMessage({ command: "update_tab", tabId: parseInt(s.id), tab: { expand: "c" } }); + }); + + document.querySelectorAll("#"+active_group+" .o.folder").forEach(function(s){ + s.classList.remove("o"); + s.classList.add("c"); + }); + thisTreeTabs.forEach(function(s){ + s.classList.remove("c"); + s.classList.add("o"); + chrome.runtime.sendMessage({ command: "update_tab", tabId: parseInt(s.id), tab: { expand: "o" } }); + }); + thisTreeFolders.forEach(function(s){ + s.classList.remove("c"); + s.classList.add("o"); + }); + SaveFolders(); + if (Node.classList.contains("tab")) { + ScrollToTab(Node.id); + } } else { - chrome.tabs.create({}); + Node.classList.remove("c"); + Node.classList.add("o"); + + if (Node.classList.contains("tab")) { + chrome.runtime.sendMessage({ command: "update_tab", tabId: parseInt(Node.id), tab: { expand: "o" } }); + } + + if (Node.classList.contains("folder")) { + SaveFolders(); + } + } } - }); - $(document).on("mouseenter", ".close", function(event) { - $(this).addClass("close_hover"); - }); - $(document).on("mouseleave", ".close", function(event) { - $(".close_hover").removeClass("close_hover"); - }); - $(document).on("mouseenter", ".expand", function(event) { - $(this).addClass("hover"); - }); - $(document).on("mouseleave", ".expand", function(event) { - $(".expand.hover").removeClass("hover"); - }); - $(document).on("mouseover", ".tab_header", function(event) { - $(this).addClass("tab_header_hover"); - if (opt.always_show_close == false) { - $(this).addClass("close_show"); + } +} + + +function OpenNewTab(pin, parentId) { + if (pin) { + chrome.tabs.create({pinned: true}, function(tab) { + if (parentId) { + AppendTab(tab, "pin_list", false, parentId, true, false, true, false, false, true, false); + schedule_update_data++; + } + }); + } else { + chrome.tabs.create({}, function(tab) { + if (parentId) { + AppendTab(tab, parentId, false, false, (opt.append_orphan_tab == "top" ? false : true), false, true, false, false, true, false); + schedule_update_data++; + } + }); + } +} + + +function EventSelectTab(event, TabNode) { + DeselectFolders(); + if (event.shiftKey) { // SET SELECTION WITH SHIFT + let activeTab = document.querySelector("#"+active_group+" .selected_tab.selected_last"); + if (activeTab == null) { + activeTab = document.querySelector(".pin.active_tab, #"+active_group+" .tab.active_tab"); } - }); - $(document).on("mouseleave", ".tab_header", function(event) { - $(this).removeClass("tab_header_hover"); - if (opt.always_show_close == false) { - $(this).removeClass("close_show"); - } - }); - $(document).on("mousedown", ".expand", function(event) { // EXPAND BOX - EXPAND / COLLAPSE - if (event.button == 0) { - if ($(this).parent().parent().is(".o")) { - $(this).parent().parent().removeClass("o").addClass("c"); - chrome.runtime.sendMessage({ command: "update_tab", tabId: parseInt($(this).parent().parent()[0].id), tab: { expand: "c" } }); - } else { - if ($(this).parent().parent().is(".c")) { - $(this).parent().parent().removeClass("c").addClass("o"); - chrome.runtime.sendMessage({command: "update_tab", tabId: parseInt($(this).parent().parent()[0].id), tab: { expand: "o" } }); - if (opt.close_other_trees) { - $(".o:visible:not(#"+$(this).parent().parent()[0].id+")").removeClass("o").addClass("c"); - $(this).parents(".tab").each(function() { - $(this).removeClass("n").removeClass("c").addClass("o"); - chrome.runtime.sendMessage({ command: "update_tab", tabId: parseInt(this.id), tab: { expand: "o" } }); - }); - $(".c").each(function() { - chrome.runtime.sendMessage({ command: "update_tab", tabId: parseInt(this.id), tab: { expand: "c" } }); - }); - } + if (activeTab != null && TabNode.parentNode.id == activeTab.parentNode.id) { + + if (!event.ctrlKey) { + document.querySelectorAll(".pin.selected_tab, #"+active_group+" .selected_tab").forEach(function(s){ + s.classList.remove("selected_frozen"); + s.classList.remove("selected_temporarly"); + s.classList.remove("selected_tab"); + s.classList.remove("selected_last"); + }); + } + let ChildrenArray = Array.from(TabNode.parentNode.children); + let activeTabIndex = ChildrenArray.indexOf(activeTab); + let thisTabIndex = ChildrenArray.indexOf(TabNode); + let fromIndex = thisTabIndex >= activeTabIndex ? activeTabIndex : thisTabIndex; + let toIndex = thisTabIndex >= activeTabIndex ? thisTabIndex : activeTabIndex; + for (let i = fromIndex; i <= toIndex; i++) { + activeTab.parentNode.childNodes[i].classList.add("selected_tab"); + if (i == toIndex && event.ctrlKey) { + activeTab.parentNode.childNodes[i].classList.add("selected_last"); } } } - }); - $(document).on("mousedown", ".tab, .pin", function(event) { // SELECT TAB/PIN - if ($(".menu").is(":visible")) { - return; + } + if (event.ctrlKey && !event.shiftKey) { // TOGGLE SELECTION WITH CTRL + TabNode.classList.toggle("selected_tab"); + if (TabNode.classList.contains("selected_tab")) { + document.querySelectorAll(".selected_last").forEach(function(s){ + s.classList.remove("selected_last"); + }); + TabNode.classList.add("selected_last"); + } else { + TabNode.classList.remove("selected_last"); } - event.stopPropagation(); - if (event.button == 0) { - $("#"+active_group+" .folder").removeClass("selected_folder"); - let tabId = parseInt(this.id); - if (event.shiftKey) { // SET SELECTION WITH SHIFT - $(".pin, .tab:visible").removeClass("selected_tab").removeClass("selected_frozen").removeClass("selected_temporarly"); - if ($(this).index() >= $(".active_tab:visible").index()) { - $(".active_tab:visible").nextUntil($(this), ":visible").add($(".active_tab:visible")).add($(this)).addClass("selected_tab"); - } else { - $(".active_tab:visible").prevUntil($(this), ":visible").add($(".active_tab:visible")).add($(this)).addClass("selected_tab"); - } - } - if (event.ctrlKey) { // TOGGLE SELECTION WITH CTRL - // if ($(".active_tab:visible").is(":not(.selected_tab)")) { - // $(".active_tab:visible").addClass("selected_tab"); - // } - $(this).toggleClass("selected_tab"); - } + } +} + +function ActionClickTab(TabNode, bgOption) { + if (bgOption == "new_tab") { + OpenNewTab(TabNode.classList.contains("pin"), TabNode.id); + } + if (bgOption == "expand_collapse") { + EventExpandBox(TabNode); + } + if (bgOption == "close_tab") { + if ((TabNode.classList.contains("pin") && opt.allow_pin_close) || TabNode.classList.contains("tab")) { + CloseTabs([parseInt(TabNode.id)]); } - }); - $(document).on("mousedown", ".tab_header", function(event) { // CLOSE TAB/PIN - let tabId = parseInt($(this).parent()[0].id); - if ((event.button == 1 && opt.close_with_MMB == true && $(this).parent().is(".tab")) || (event.button == 1 && opt.close_with_MMB == true && $(this).parent().is(".pin") && opt.allow_pin_close == true) || (event.button == 0 && $(event.target).is(".close, .close_img"))) { - if ($(this).parent().is(".active_tab:visible") && opt.after_closing_active_tab != "browser") { - ActionBeforeTabsClose(); - } // hide pin before it will be closed by listener - $(".pin#"+tabId).css({ "width": "0px", "height": "0px", "border": "none", "overflow": "hidden" }); - chrome.tabs.update(tabId, {pinned: false}); - setTimeout(function() { - if ($("#"+tabId)[0]) { - chrome.tabs.remove(tabId); - } - }, 100); - } - if (event.button == 2) { - event.stopPropagation(); - ShowTabMenu($(this).parent(), event); - } - }); - $(document).on("click", ".tab_header", function(event) { // SINGLE CLICK TO ACTIVATE TAB - if ($(".menu").is(":visible") || ($(this).parent().is(".c, .o") && $(event.target).is(".expand")) || $(event.target).is(".close, .close_img, .tab_mediaicon")) { - return; - } - event.stopPropagation(); - if (event.button == 0 && !event.shiftKey && !event.ctrlKey) { - SetActiveTab($(this).parent()[0].id); - chrome.tabs.update(parseInt($(this).parent()[0].id), { active: true }); - } - }); -} \ No newline at end of file + } + if (bgOption == "reload_tab") { + chrome.tabs.reload(parseInt(TabNode.id)); + } + if (bgOption == "unload_tab") { + SwitchActiveTabBeforeClose(active_group); + DiscardTabs([parseInt(TabNode.id)]); + } + if (bgOption == "activate_previous_active" && TabNode.classList.contains("active_tab")) { + chrome.tabs.update(parseInt(bggroups[active_group].prev_active_tab), {active: true}); + } +} diff --git a/scripts/toolbar.js b/scripts/toolbar.js index 132f90f..0581af2 100644 --- a/scripts/toolbar.js +++ b/scripts/toolbar.js @@ -4,366 +4,572 @@ // ********** TOOLBAR *************** +// RESTORE LAST USED SEARCH TYPE (URL OR TITLE) IN TOOLBAR SEARCH function RestoreToolbarSearchFilter() { chrome.runtime.sendMessage({command: "get_search_filter", windowId: CurrentWindowId}, function(response) { + let ButtonFilter = document.getElementById("button_filter_type"); if (response == "url") { - $("#button_filter_type").addClass("url").removeClass("title"); + ButtonFilter.classList.add("url"); + ButtonFilter.classList.remove("title"); } else { - $("#button_filter_type").addClass("title").removeClass("url"); + ButtonFilter.classList.add("title"); + ButtonFilter.classList.remove("url"); } }); } +// RESTORE LAST ACTIVE SHELF (SEARCH, TOOLS, GROUPS, SESSION OR FOLDER) IN TOOLBAR function RestoreToolbarShelf() { chrome.runtime.sendMessage({command: "get_active_shelf", windowId: CurrentWindowId}, function(response) { - $("#filter_box").attr("placeholder", caption_searchbox); - $("#filter_box").css({"opacity": 1}); - $(".on").removeClass("on"); - $(".toolbar_shelf").addClass("hidden"); - if (response == "search" && $("#button_search").length != 0) { - $("#toolbar_search").removeClass("hidden"); - $("#button_search").addClass("on"); + let filterBox = document.getElementById("filter_box"); + filterBox.setAttribute("placeholder", caption_searchbox); + filterBox.style.opacity = "1"; + + document.querySelectorAll(".on").forEach(function(s){ + s.classList.remove("on"); + }); + document.querySelectorAll(".toolbar_shelf").forEach(function(s){ + s.classList.add("hidden"); + }); + + if (response == "search" && document.getElementById("button_search") != null) { + document.getElementById("toolbar_search").classList.remove("hidden"); + document.getElementById("button_search").classList.add("on"); } - if (response == "tools" && $("#button_tools").length != 0) { - $("#toolbar_shelf_tools").removeClass("hidden"); - $("#button_tools").addClass("on"); + + if (response == "tools" && document.getElementById("button_tools") != null) { + document.getElementById("toolbar_shelf_tools").classList.remove("hidden"); + document.getElementById("button_tools").classList.add("on"); } - if (response == "groups" && $("#button_groups").length != 0) { - $("#toolbar_shelf_groups").removeClass("hidden"); - $("#button_groups").addClass("on"); + + if (response == "groups" && document.getElementById("button_groups") != null) { + document.getElementById("toolbar_shelf_groups").classList.remove("hidden"); + document.getElementById("button_groups").classList.add("on"); } - if (response == "backup" && $("#button_backup").length != 0) { - $("#toolbar_shelf_backup").removeClass("hidden"); - $("#button_backup").addClass("on"); + + if (response == "backup" && document.getElementById("button_backup") != null) { + document.getElementById("toolbar_shelf_backup").classList.remove("hidden"); + document.getElementById("button_backup").classList.add("on"); } - if (response == "folders" && $("#button_folders").length != 0) { - $("#toolbar_shelf_folders").removeClass("hidden"); - $("#button_folders").addClass("on"); + + if (response == "folders" && document.getElementById("button_folders") != null) { + document.getElementById("toolbar_shelf_folders").classList.remove("hidden"); + document.getElementById("button_folders").classList.add("on"); } if (browserId != "F") { - let bak1 = LoadData("windows_BAK1", []); - let bak2 = LoadData("windows_BAK2", []); - let bak3 = LoadData("windows_BAK3", []); - - if (bak1.length && $(".button#button_load_bak1")[0]) { - $(".button#button_load_bak1").removeClass("disabled"); - } else { - $(".button#button_load_bak1").addClass("disabled"); - } - - if (bak2.length && $(".button#button_load_bak2")[0]) { - $(".button#button_load_bak2").removeClass("disabled"); - } else { - $(".button#button_load_bak2").addClass("disabled"); - } - - if (bak3.length && $(".button#button_load_bak3")[0]) { - $(".button#button_load_bak3").removeClass("disabled"); - } else { - $(".button#button_load_bak3").addClass("disabled"); - } + chrome.storage.local.get(null, function(storage) { + let bak1 = storage["windows_BAK1"] ? storage["windows_BAK1"] : []; + let bak2 = storage["windows_BAK2"] ? storage["windows_BAK2"] : []; + let bak3 = storage["windows_BAK3"] ? storage["windows_BAK3"] : []; + + if (bak1.length && document.getElementById("#button_load_bak1") != null) { + document.getElementById("button_load_bak1").classList.remove("disabled"); + } else { + document.getElementById("button_load_bak1").classList.add("disabled"); + } + + if (bak2.length && document.getElementById("#button_load_bak2") != null) { + document.getElementById("button_load_bak2").classList.remove("disabled"); + } else { + document.getElementById("button_load_bak2").classList.add("disabled"); + } + + if (bak3.length && document.getElementById("#button_load_bak3") != null) { + document.getElementById("button_load_bak3").classList.remove("disabled"); + } else { + document.getElementById("button_load_bak3").classList.add("disabled"); + } + + }); } RefreshGUI(); }); } -function SetToolbarShelfToggle(click_type) { - // tools and search buttons toggle - $(document).on(click_type, "#button_tools, #button_search, #button_groups, #button_backup, #button_folders", function(event) { - if (event.button == 0) { - if ($(this).is(".on")) { - $(".on").removeClass("on"); - $(".toolbar_shelf").addClass("hidden"); - chrome.runtime.sendMessage({command: "set_active_shelf", active_shelf: "", windowId: CurrentWindowId}); - } else { - $(".toolbar_shelf").addClass("hidden"); - if ($(this).is("#button_tools")) { - $("#toolbar_shelf_tools").removeClass("hidden"); - chrome.runtime.sendMessage({command: "set_active_shelf", active_shelf: "tools", windowId: CurrentWindowId}); - } - if ($(this).is("#button_search")) { - $("#toolbar_search").removeClass("hidden"); - chrome.runtime.sendMessage({command: "set_active_shelf", active_shelf: "search", windowId: CurrentWindowId}); - } - if ($(this).is("#button_groups")) { - $("#toolbar_shelf_groups").removeClass("hidden"); - chrome.runtime.sendMessage({command: "set_active_shelf", active_shelf: "groups", windowId: CurrentWindowId}); - } - if ($(this).is("#button_backup")) { - $("#toolbar_shelf_backup").removeClass("hidden"); - chrome.runtime.sendMessage({command: "set_active_shelf", active_shelf: "backup", windowId: CurrentWindowId}); - } - if ($(this).is("#button_folders")) { - $("#toolbar_shelf_folders").removeClass("hidden"); - chrome.runtime.sendMessage({command: "set_active_shelf", active_shelf: "folders", windowId: CurrentWindowId}); - } - $(".button").removeClass("on"); - $(this).addClass("on"); - } - RefreshGUI(); +// FUNCTION TO TOGGLE SHELFS AND SAVE IT +function ShelfToggle(mousebutton, button, toolbarId, SendMessage) { + if (mousebutton == 1) { + if (button.classList.contains("on")) { + document.querySelectorAll(".on").forEach(function(s){ + s.classList.remove("on"); + }); + document.querySelectorAll(".toolbar_shelf").forEach(function(s){ + s.classList.add("hidden"); + }); + } else { + document.querySelectorAll(".toolbar_shelf:not(#"+toolbarId+")").forEach(function(s){ + s.classList.add("hidden"); + }); + document.getElementById(toolbarId).classList.remove("hidden"); + chrome.runtime.sendMessage({command: "set_active_shelf", active_shelf: SendMessage, windowId: CurrentWindowId}); + document.querySelectorAll(".on:not(#"+button.id+")").forEach(function(s){ + s.classList.remove("on"); + }); + button.classList.add("on"); } - }); + RefreshGUI(); + } } +// ASSIGN MOUSE EVENTS FOR TOOLBAR BUTTONS, Buttons AND ToolbarShelfToggle, PARAMETERS DECIDE IF BUTTONS ARE CLICKABLE +// IN OPTIONS PAGE - TOOLBAR BUTTONS SAMPLES, MUST NOT CALL FUNCTIONS ON CLICKS, BUT STILL SHELFS BUTTONS MUST TOGGLE AND MOREOVER ON CLICK AND NOT ON MOUSEDOWN THIS IS WHERE ToolbarShelfToggleClickType="Click" IS NECESSARY +function SetToolbarEvents(CleanPreviousBindings, Buttons, ToolbarShelfToggle, ToolbarShelfToggleClickType) { -function SetToolbarEvents() { - // go to previous or next search result - $(document).on("mousedown", "#filter_search_go_prev, #filter_search_go_next", function(event) { - if (event.button != 0 || $(".tab.filtered").length == 0) { - return; - } - - $(".highlighted_search").removeClass("highlighted_search"); - if ($(this).is("#filter_search_go_prev")){ - if (SearchIndex == 0) { - SearchIndex = $(".tab.filtered").length-1; - } else { - SearchIndex--; + let ClearSearch = document.getElementById("button_filter_clear"); + let FilterBox = document.getElementById("filter_box"); + + if (ClearSearch != null && FilterBox != null) { + if (CleanPreviousBindings) { + FilterBox.removeEventListener("oninput", function(){}); + ClearSearch.removeEventListener("onmousedown", function(){}); + } + if (Buttons) { + // FILTER ON INPUT + FilterBox.oninput = function(event) { + FindTab(this.value); } - } else { - if (SearchIndex == $(".tab.filtered").length-1) { - SearchIndex = 0; - } else { - SearchIndex++; - } - } - ScrollToTab($(".tab.filtered")[SearchIndex].id); - $($(".tab.filtered")[SearchIndex]).addClass("highlighted_search"); - }); - // new tab - $(document).on("mousedown", "#button_new", function(event) { - if (event.button == 1 && $(".active_tab:visible")[0]) { - chrome.tabs.duplicate(parseInt($(".active_tab:visible")[0].id), function(tab) { - setTimeout(function() { - $("#"+tab.id).insertAfter($(".active_tab:visible")[0]); - RefreshExpandStates(); - schedule_update_data++; - RefreshCounters(); - }, 100); - }); - } - if (event.button == 2 && $("#"+active_group+" .active_tab")[0]) { - ScrollToTab($("#"+active_group+" .active_tab")[0].id); - } - }); - $(document).on("click", "#button_new", function(event) { - if (event.button == 0) { - chrome.tabs.create({}); - } - }); - // pin tab - $(document).on("mousedown", "#button_pin", function(event) { - if (event.button == 0) { - $(".active_tab:visible, .selected_tab:visible").each(function() { - chrome.tabs.update(parseInt(this.id), { pinned: ($(this).is(".pin") ? false : true) }); - }); - } - }); - // undo close - $(document).on("mousedown", "#button_undo", function(event) { - if (event.button == 0) { - chrome.sessions.getRecentlyClosed( null, function(sessions) { - if (sessions.length > 0) { - chrome.sessions.restore(null, function(restored) { - // if (browserId == "F") { - // if (restored.tab != undefined) { - // let t = Promise.resolve(browser.sessions.getTabValue(restored.tab.id, "TTId")).then(function(TTId) { - // TODO RESTORE TREE IF POSSIBLE - // console.log(TTId); - // }); - // } - // } - }); + // CLEAR FILTER BUTTON + ClearSearch.onmousedown = function(event) { + if (event.which == 1) { + this.style.opacity = "0"; + this.style.opacity = "0"; + this.setAttribute("title", ""); + FindTab(""); } - }); - } - }); - // move tab to new window (detach) - $(document).on("mousedown", "#button_move", function(event) { - if (event.button == 0) { - if ($("#"+active_group+" .selected_tab")[0]){ - let detach = GetSelectedTabs(); - DetachTabs(detach.TabsIds, {}); - } else { - if ($("#"+active_group+" .selected_folder")[0]){ - let detach = GetSelectedFolders(); - DetachTabs(detach.TabsIds, detach.Folders); - } } } - }); - // move tab to new window (detach) - $(document).on("mousedown", "#repeat_search", function(event) { - if (event.button == 0) { - FindTab($("#filter_box")[0].value); - } - }); - // filter on input - $("#filter_box").on("input", function() { - FindTab($("#filter_box")[0].value); - }); - // change filtering type - $(document).on("mousedown", "#button_filter_type", function(event) { - if (event.button == 0) { - if ($("#button_filter_type").is(".url")) { - $("#button_filter_type").removeClass("url").addClass("title"); - } else { - $("#button_filter_type").addClass("url").removeClass("title"); - } - FindTab($("#filter_box")[0].value); - chrome.runtime.sendMessage({command: "set_search_filter", search_filter: ($(this).is(".url") ? "url" : "title"), windowId: CurrentWindowId}); - } - }); - // clear filter button - $(document).on("mousedown", "#button_filter_clear", function(event) { - if (event.button == 0) { - $("#button_filter_clear").css({"opacity": "0"}).attr("title", ""); - FindTab(""); - } - }); - // sort tabs - // $(document).on("mousedown", "#button_sort", function(event) { - // if (event.button == 0) { - // SortTabs(); - // } - // }); - // vertical tabs options - $(document).on("mousedown", "#button_options", function(event) { - if (event.button == 0) { - chrome.tabs.create({url: "options.html" }); - } - }); - // new group - $(document).on("mousedown", "#button_new_group", function(event) { - if (event.button == 0) { - AddNewGroup({}); - } - }); - // remove group - $(document).on("mousedown", "#button_remove_group", function(event) { - let close_tabs = event.shiftKey; - if (event.button == 0) { - if (active_group != "tab_list") { - GroupRemove(active_group, close_tabs); - } - } - }); - // edit group - $(document).on("mousedown", "#button_edit_group", function(event) { - if (event.button == 0 && active_group != "tab_list") { - menuItemId = active_group; - ShowGroupEditWindow(); - } - }); - // import-export group - $(document).on("mousedown", "#button_export_group", function(event) { - if (event.button == 0) { - ExportGroup(bggroups[active_group].name+".tt_group"); - } - }); - $(document).on("mousedown", "#button_import_group", function(event) { - if (event.button == 0) { - ShowOpenFileDialog("file_import_group", ".tt_group"); - } - }); - $(document).on("change", "#file_import_group", function(event) { - ImportGroup(); - }); - - - // new folder - $(document).on("mousedown", "#button_new_folder", function(event) { - if (event.button == 0) { - AddNewFolder({}); - } - }); - // rename folder - $(document).on("mousedown", "#button_edit_folder", function(event) { - if (event.button == 0 && $(".selected_folder:visible")[0]) { - ShowRenameFolderDialog($(".selected_folder:visible")[0].id); - } - }); - // remove folder - $(document).on("mousedown", "#button_remove_folder", function(event) { - // let close_tabs = event.shiftKey; - if (event.button == 0 && $(".selected_folder:visible")[0]) { - $("#"+active_group+" .selected_folder").each(function() { - RemoveFolder(this.id); - }); - // RemoveFolder($(".selected_folder:visible")[0].id); - } - }); - // discard tabs - $(document).on("mousedown", "#button_discard", function(event) { - if (event.button == 0) { - DiscardTabs($(".selected_tab")[0] ? ($(".selected_tab").map(function() { return parseInt(this.id); }).toArray()) : ($(".pin, .tab").map(function() { return parseInt(this.id); }).toArray()) ); - } - }); - - if (browserId != "F") { - // bookmarks - $(document).on("mousedown", "#button_bookmarks", function(event) { - if (event.button == 0) { - chrome.tabs.create({url: "chrome://bookmarks/"}); - } - }); - // downloads - $(document).on("mousedown", "#button_downloads", function(event) { - if (event.button == 0) { - chrome.tabs.create({url: "chrome://downloads/"}); - } - }); - // history - $(document).on("mousedown", "#button_history", function(event) { - if (event.button == 0) { - chrome.tabs.create({url: "chrome://history/"}); - } - }); - // extensions - $(document).on("mousedown", "#button_extensions", function(event) { - if (event.button == 0) { - chrome.tabs.create({url: "chrome://extensions"}); - } - }); - // settings - $(document).on("mousedown", "#button_settings", function(event) { - if (event.button == 0) { - chrome.tabs.create({url: "chrome://settings/"}); - } - }); - // load backups - $(document).on("mousedown", "#button_load_bak1:not(.disabled), #button_load_bak2:not(.disabled), #button_load_bak3:not(.disabled)", function(event) { - if (event.button == 0) { - let BakN = (this.id).substr(15); - chrome.storage.local.get(null, function(items) { - if (Object.keys(items["windows_BAK"+BakN]).length > 0) { chrome.storage.local.set({"windows": items["windows_BAK"+BakN]}); } - if (Object.keys(items["tabs_BAK"+BakN]).length > 0) { chrome.storage.local.set({"tabs": items["tabs_BAK"+BakN]}); alert("Loaded backup"); } - chrome.runtime.sendMessage({command: "reload"}); chrome.runtime.sendMessage({command: "reload_sidebar"}); location.reload(); - }); - } - }); } - // import-export backups - $(document).on("mousedown", "#button_export_bak", function(event) { - ExportSession("Session.tt_session"); - }); + document.querySelectorAll(".button").forEach(function(s){ + + if (CleanPreviousBindings) { + s.removeEventListener("onmousedown", function(){}); + s.removeEventListener("onclick", function(){}); + s.removeEventListener("click", function(){}); + } + + if (ToolbarShelfToggle) { + if (s.id == "button_search") { + s.addEventListener(ToolbarShelfToggleClickType, function(event) { + if (event.which == 1) { + ShelfToggle(event.which, this, "toolbar_search", "search"); + } + }); + } + if (s.id == "button_tools") { + s.addEventListener(ToolbarShelfToggleClickType, function(event) { + if (event.which == 1) { + ShelfToggle(event.which, this, "toolbar_shelf_tools", "tools"); + } + }); + } + if (s.id == "button_groups") { + s.addEventListener(ToolbarShelfToggleClickType, function(event) { + if (event.which == 1) { + ShelfToggle(event.which, this, "toolbar_shelf_groups", "groups"); + } + }); + } + if (s.id == "button_backup") { + s.addEventListener(ToolbarShelfToggleClickType, function(event) { + if (event.which == 1) { + ShelfToggle(event.which, this, "toolbar_shelf_backup", "backup"); + } + }); + } + if (s.id == "button_folders") { + s.addEventListener(ToolbarShelfToggleClickType, function(event) { + if (event.which == 1) { + ShelfToggle(event.which, this, "toolbar_shelf_folders", "folders"); + } + }); + } + } + + if (Buttons) { + // NEW TAB + if (s.id == "button_new") { + s.onclick = function(event) { + if (event.which == 1) { + OpenNewTab(); + } + } + s.onmousedown = function(event) { + // DUPLICATE TAB + if (event.which == 2) { + event.preventDefault(); + let activeTab = document.querySelector("#"+active_group+" .active_tab") != null ? document.querySelector("#"+active_group+" .active_tab") : document.querySelector(".pin.active_tab") != null ? document.querySelector(".pin.active_tab") : null; + if (activeTab != null) { + chrome.tabs.duplicate(parseInt(activeTab.id), function(tab) { + setTimeout(function() { + if (activeTab.nextSibling != null) { + activeTab.parentNode.insertBefore(document.getElementById(tab.id), activeTab.nextSibling); + } else { + activeTab.parentNode.appendChild(document.getElementById(tab.id)); + } + RefreshExpandStates(); + schedule_update_data++; + RefreshCounters(); + }, 300); + }); + } + } + // SCROLL TO TAB + if (event.which == 3) { + let activeTab = document.querySelector("#"+active_group+" .active_tab") != null ? document.querySelector("#"+active_group+" .active_tab") : document.querySelector(".pin.active_tab") != null ? document.querySelector(".pin.active_tab") : null; + if (activeTab != null) { + ScrollToTab(activeTab.id); + } + } + } + } + // PIN TAB + if (s.id == "button_pin") { + s.onmousedown = function(event) { + if (event.which == 1) { + let Tabs = document.querySelectorAll(".pin.active_tab, .pin.selected_tab, #"+active_group+" .active_tab, #"+active_group+" .selected_tab"); + Tabs.forEach(function(s){ + chrome.tabs.update(parseInt(s.id), { pinned: Tabs[0].classList.contains("tab") }); + }) + } + } + } + // VERTICAL TABS OPTIONS + if (s.id == "button_options") { + s.onmousedown = function(event) { + if (event.which == 1) { + chrome.tabs.create({url: "options.html"}); + } + } + } + + // UNDO CLOSE + if (s.id == "button_undo") { + s.onmousedown = function(event) { + if (event.which == 1) { + chrome.sessions.getRecentlyClosed( null, function(sessions) { + if (sessions.length > 0) { + chrome.sessions.restore(null, function(restored) {}); + } + }); + } + } + } + + // MOVE TAB TO NEW WINDOW (DETACH) + if (s.id == "button_detach" || s.id == "button_move") { + s.onmousedown = function(event) { + if (event.which == 1) { + if (document.querySelectorAll("#"+active_group+" .selected_folder").length > 0){ + let detach = GetSelectedFolders(); + Detach(detach.TabsIds, detach.Folders); + } else { + let tabsArr = []; + document.querySelectorAll(".pin.selected_tab, .pin.active_tab, #"+active_group+" .selected_tab, #"+active_group+" .active_tab").forEach(function(s){ + tabsArr.push(parseInt(s.id)); + if (s.childNodes[4].childNodes.length > 0) { + document.querySelectorAll("#"+s.childNodes[4].id+" .tab").forEach(function(t){ + tabsArr.push(parseInt(t.id)); + }); + } + }); + Detach(tabsArr); + } + } + } + } + + // SHOW/HIDE GROUPS TOOLBAR + if (s.id == "button_groups_toolbar_hide") { + s.onmousedown = function(event) { + if (event.which == 1) { + GroupsToolbarToggle(); + } + } + } + + // GO TO PREVIOUS SEARCH RESULT + if (s.id == "filter_search_go_prev") { + s.onmousedown = function(event) { + if (event.which == 1) { + let filtered = document.querySelectorAll("#"+active_group+" .tab.filtered"); + if (filtered.length > 0) { + document.querySelectorAll(".highlighted_search").forEach(function(s){ + s.classList.remove("highlighted_search"); + }); + if (SearchIndex == 0) { + SearchIndex = filtered.length-1; + } else { + SearchIndex--; + } + filtered[SearchIndex].classList.add("highlighted_search"); + ScrollToTab(filtered[SearchIndex].id); + } + } + } + } - $(document).on("mousedown", "#button_import_bak", function(event) { - ShowOpenFileDialog("file_import_backup", ".tt_session"); - }); - $(document).on("change", "#file_import_backup", function(event) { - ImportSession(); - }); + // GO TO NEXT SEARCH RESULT + if (s.id == "filter_search_go_next") { + s.onmousedown = function(event) { + if (event.which == 1) { + let filtered = document.querySelectorAll("#"+active_group+" .tab.filtered"); + if (filtered.length > 0) { + document.querySelectorAll(".highlighted_search").forEach(function(s){ + s.classList.remove("highlighted_search"); + }); + if (SearchIndex == filtered.length-1) { + SearchIndex = 0; + } else { + SearchIndex++; + } + filtered[SearchIndex].classList.add("highlighted_search"); + ScrollToTab(filtered[SearchIndex].id); + } + } + } + } + + // NEW GROUP + if (s.id == "button_new_group") { + s.onmousedown = function(event) { + if (event.which == 1) { + AddNewGroup(); + } + } + } + // REMOVE GROUP + if (s.id == "button_remove_group") { + s.onmousedown = function(event) { + if (event.which == 1) { + if (active_group != "tab_list") { + GroupRemove(active_group, event.shiftKey); + } + } + } + } + + + + // EDIT GROUP + if (s.id == "button_edit_group") { + s.onmousedown = function(event) { + if (event.which == 1) { + if (active_group != "tab_list") { + ShowGroupEditWindow(active_group); + } + } + } + } + + // EXPORT GROUP + if (s.id == "button_export_group") { + s.onmousedown = function(event) { + if (event.which == 1) { + ExportGroup(bggroups[active_group].name+".tt_group"); + } + } + } + + // IMPORT GROUP + if (s.id == "button_import_group") { + s.onmousedown = function(event) { + if (event.which == 1) { + let inputFile = ShowOpenFileDialog("file_import_group", ".tt_group"); + inputFile.onchange = function(event) { + ImportGroup(); + // this.parentNode.removeChild(this); + } + } + } + } + + // NEW FOLDER + if (s.id == "button_new_folder") { + s.onmousedown = function(event) { + if (event.which == 1) { + AddNewFolder(); + } + } + } + + // RENAME FOLDER + if (s.id == "button_edit_folder") { + s.onmousedown = function(event) { + if (event.which == 1) { + if (document.querySelectorAll("#"+active_group+" .selected_folder").length > 0) { + ShowRenameFolderDialog(document.querySelectorAll("#"+active_group+" .selected_folder")[0].id); + } + } + } + } + // REMOVE FOLDERS + if (s.id == "button_remove_folder") { + s.onmousedown = function(event) { + if (event.which == 1) { + document.querySelectorAll("#"+active_group+" .selected_folder").forEach(function(s){ + RemoveFolder(s.id); + }); + } + } + } + // DISCARD TABS + if (s.id == "button_unload" || s.id == "button_discard") { + s.onmousedown = function(event) { + if (event.which == 1) { + if (document.querySelectorAll(".pin.selected_tab:not(.active_tab), #"+active_group+" .selected_tab:not(.active_tab)").length > 0) { + DiscardTabs( + Array.prototype.map.call(document.querySelectorAll(".pin:not(.active_tab), #"+active_group+" .selected_tab:not(.active_tab)"), function(s){ + return parseInt(s.id); + }) + ); + } else { + DiscardTabs( + Array.prototype.map.call(document.querySelectorAll(".pin:not(.active_tab), .tab:not(.active_tab)"), function(s){ + return parseInt(s.id); + }) + ); + } + } + } + } + // IMPORT BACKUP + if (s.id == "button_import_bak") { + s.onmousedown = function(event) { + if (event.which == 1) { + let inputFile = ShowOpenFileDialog("file_import_backup", ".tt_session"); + inputFile.onchange = function(event) { + ImportSession(); + // this.remove(); + } + } + } + } + // EXPORT BACKUP + if (s.id == "button_export_bak") { + s.onmousedown = function(event) { + if (event.which == 1) { + ExportSession("Session.tt_session"); + } + } + } + // MERGE BACKUP + if (s.id == "button_import_merge_bak") { + s.onmousedown = function(event) { + if (event.which == 1) { + let inputFile = ShowOpenFileDialog("file_import_merge_backup", ".tt_session"); + inputFile.onchange = function(event) { + ImportMergeTabs(); + // this.remove(); + } + } + } + } + + // CHANGE FILTERING TYPE + if (s.id == "button_filter_type") { + s.onmousedown = function(event) { + if (event.which == 1) { + if (this.classList.contains("url")) { + this.classList.remove("url"); + this.classList.add("title"); + chrome.runtime.sendMessage({command: "set_search_filter", search_filter: "title", windowId: CurrentWindowId}); + } else { + this.classList.remove("title"); + this.classList.add("url"); + chrome.runtime.sendMessage({command: "set_search_filter", search_filter: "url", windowId: CurrentWindowId}); + } + FindTab(document.getElementById("filter_box").value); + } + } + } + + // SORT TABS + // if (s.id == "button_sort") { + // s.onmousedown = function(event) { + // if (event.which == 1) { + // SortTabs(); + // } + // } + // } + // REPEAT SEARCH + // if (s.id == "repeat_search") { + // s.onmousedown = function(event) { + // if (event.which == 1) { + // FindTab(document.getElementById("filter_box").value); + // } + // } + // } + + + if (browserId != "F") { + // BOOKMARKS + if (s.id == "button_bookmarks") { + s.onmousedown = function(event) { + if (event.which == 1) { + chrome.tabs.create({url: "chrome://bookmarks/"}); + } + } + } + + // DOWNLOADS + if (s.id == "button_downloads") { + s.onmousedown = function(event) { + if (event.which == 1) { + chrome.tabs.create({url: "chrome://downloads/"}); + } + } + } + + // HISTORY + if (s.id == "button_history") { + s.onmousedown = function(event) { + if (event.which == 1) { + chrome.tabs.create({url: "chrome://history/"}); + } + } + } + + // EXTENSIONS + if (s.id == "button_extensions") { + s.onmousedown = function(event) { + if (event.which == 1) { + chrome.tabs.create({url: "chrome://extensions"}); + } + } + } + + // SETTINGS + if (s.id == "button_settings") { + s.onmousedown = function(event) { + if (event.which == 1) { + chrome.tabs.create({url: "chrome://settings/"}); + } + } + } + + // LOAD BACKUPS + if (s.id == "button_load_bak1" || s.id == "button_load_bak2" || s.id == "button_load_bak3") { + s.onmousedown = function(event) { + if (event.which == 1 && this.classList.contains("disabled") == false) { + let BakN = (this.id).substr(15); + chrome.storage.local.get(null, function(items) { + if (Object.keys(items["windows_BAK"+BakN]).length > 0) { chrome.storage.local.set({"windows": items["windows_BAK"+BakN]}); } + if (Object.keys(items["tabs_BAK"+BakN]).length > 0) { chrome.storage.local.set({"tabs": items["tabs_BAK"+BakN]}); alert("Loaded backup"); } + chrome.runtime.sendMessage({command: "reload"}); chrome.runtime.sendMessage({command: "reload_sidebar"}); location.reload(); + }); + } + } + } + + + } + + } - $(document).on("mousedown", "#button_import_merge_bak", function(event) { - ShowOpenFileDialog("file_import_merge_backup", ".tt_session"); - }); - $(document).on("change", "#file_import_merge_backup", function(event) { - ImportMergeTabs(); }); } \ No newline at end of file diff --git a/scripts/utils.js b/scripts/utils.js index b2ccb3e..7a1b2e8 100644 --- a/scripts/utils.js +++ b/scripts/utils.js @@ -3,112 +3,282 @@ // that can be found at https://creativecommons.org/licenses/by-nc-nd/4.0/ -// sort tabs main function -function SortTabs(){ - if ($(".tab").find(":visible:first")[0]){ - chrome.tabs.query({windowId: vt.windowId}, function(tabs){ - tabs.sort(function(tab_a, tab_b){ - return SplitUrl(tab_a).localeCompare( SplitUrl(tab_b) ); - }); - var first_tabId; - if ($(".selected:visible")[0]){ - first_tabId = parseInt($(".selected:visible")[0].id); - } else { - first_tabId = parseInt($(".tab").find(":visible:first")[0].parentNode.id); - } - chrome.tabs.get(first_tabId, function(tab){ - var new_index = tab.index; - tabs.forEach(function(Tab){ - // sort selected when more than 1 tab is selected - if (($(".selected:visible").length > 1 && $("#"+Tab.id).is(":visible") && !Tab.pinned && $("#"+Tab.id).is(".selected")) || ($(".selected:visible").length < 2 && $("#"+Tab.id).is(":visible") && !Tab.pinned)){ - chrome.tabs.move(Tab.id, {"index": new_index}); - new_index++; - } - }); - }); - if (bg.opt.scroll_to_active){ - setTimeout(function(){ - ScrollTabList($(".active:visible")[0].id); - },1000); - } - }); +function HideRenameDialogs() { + document.querySelectorAll(".edit_dialog").forEach(function(s){ + s.style.display = "none"; + s.style.top = "-500px"; + s.style.left = "-500px"; + }); +} +function GetParentsByClass(Node, Class) { + let Parents = []; + let ParentNode = Node; + while (ParentNode.parentNode != null) { + if (ParentNode.parentNode.classList != undefined && ParentNode.parentNode.classList.contains(Class)) { + Parents.push(ParentNode.parentNode); + } + ParentNode = ParentNode.parentNode; } + return Parents; +} +function GetParentsBy2Classes(Node, ClassA, ClassB) { + let Parents = []; + let ParentNode = Node; + while (ParentNode.parentNode != null) { + if (ParentNode.parentNode.classList != undefined && ParentNode.parentNode.classList.contains(ClassA) && ParentNode.parentNode.classList.contains(ClassB)) { + Parents.push(ParentNode.parentNode); + } + ParentNode = ParentNode.parentNode; + } + return Parents; } -// sort tabs sub function -function SplitUrl(tab){ - var tmp_url = new URL(tab.url); - if (tmp_url.protocol != "http:"){ - tmp_url.protocol == "http:"; - } - var url_parts = []; - if (tab.pinned){ - url_parts.push("#"+tab.index); + +function GetSelectedFolders() { + if (opt.debug) console.log("function: GetSelectedFolders"); + let res = {Folders: {}, FoldersSelected: [], TabsIds: [], TabsIdsParents: []}; + document.querySelectorAll("#"+active_group+" .selected_folder").forEach(function(s){ + res.FoldersSelected.push(s.id); + res.Folders[s.id] = Object.assign({}, bgfolders[s.id]); + let Fchildren = document.querySelectorAll("#cf"+s.id+" .folder"); + Fchildren.forEach(function(fc){ + res.Folders[fc.id] = Object.assign({}, bgfolders[fc.id]); + }); + let Tchildren = document.querySelectorAll("#ct"+s.id+" .tab"); + Tchildren.forEach(function(tc){ + res.TabsIds.push(parseInt(tc.id)); + res.TabsIdsParents.push(tc.parentNode.id); + }); + }); + if (opt.debug) console.log(res); + return res; +} + +function GetSelectedTabs() { + if (opt.debug) console.log("function: GetSelectedTabs"); + // let res = {urls: [], TabsIds: [], TabsIdsParents: [], TabsIdsSelected: []}; + let res = {TabsIds: [], TabsIdsParents: [], TabsIdsSelected: []}; + document.querySelectorAll(".pin.selected_tab, #"+active_group+" .selected_tab").forEach(function(s){ + // chrome.tabs.get(parseInt(s.id), function(tab) { + // res.urls.push(tab.url); + // }); + + res.TabsIds.push(parseInt(s.id)); + res.TabsIdsParents.push(s.parentNode.id); + res.TabsIdsSelected.push(parseInt(s.id)); + let Tchildren = document.querySelectorAll("#ct"+s.id+" .tab"); + Tchildren.forEach(function(tc){ + + // chrome.tabs.get(parseInt(tc.id), function(tab) { + // res.urls.push(tab.url); + // }); + + res.TabsIds.push(parseInt(tc.id)); + res.TabsIdsParents.push(tc.parentNode.id); + }); + }); + if (opt.debug) console.log(res); + return res; +} + + + + + +function FindTab(input) { // find and select tabs + let ButtonFilterClear = document.getElementById("button_filter_clear"); + document.querySelectorAll(".filtered, .highlighted_search").forEach(function(s){ + s.classList.remove("filtered"); + s.classList.remove("selected_tab"); + s.classList.remove("selected_last"); + s.classList.remove("highlighted_search"); + }) + if (input.length == 0) { + document.getElementById("filter_box").value = ""; + ButtonFilterClear.style.opacity = "0"; + ButtonFilterClear.title = ""; + return; } else { - url_parts.push("~"); + ButtonFilterClear.style.opacity = "1"; + ButtonFilterClear.title = caption_clear_filter; } - var parts = tmp_url.host.split("."); - parts.reverse(); - if (parts.length > 1){ - parts = parts.slice(1); - } - parts.join("."); - url_parts.push(parts); - url_parts.push(tab.title.toLowerCase()); - return url_parts.join(" ! "); -} - - -// bookmark main function -function BookmarkTabs(tabs_array, FolderName){ - var rootId; - var vertical_tabs_folderId; - chrome.bookmarks.getRootByName("bookmarks_bar", function(tree){ - rootId = tree.id; - chrome.bookmarks.search("VerticalTabs", function(list){ - for (var elem in list) { - if (list[elem].parentId == rootId){ - vertical_tabs_folderId = list[elem].id; - break; + SearchIndex = 0; + let FilterType = document.getElementById("button_filter_type"); + let searchUrl = FilterType.classList.contains("url"); + let searchTitle = FilterType.classList.contains("title"); + chrome.tabs.query({windowId: CurrentWindowId, pinned: false}, function(tabs) { + tabs.forEach(function(Tab) { + if (searchUrl) { + if (Tab.url.toLowerCase().match(input.toLowerCase())) { + document.getElementById(Tab.id).classList.add("filtered"); + document.getElementById(Tab.id).classList.add("selected_tab"); } } - if (vertical_tabs_folderId == undefined){ - chrome.bookmarks.create({parentId: rootId, title: "VerticalTabs"}, function(vertical_tabs_new){ - vertical_tabs_folderId = vertical_tabs_new.id; - }); - } - chrome.bookmarks.search(FolderName, function(list){ - for (var elem in list) { - if (list[elem].parentId == vertical_tabs_folderId){ - SlowlyBookmarkTabs(tabs_array, list[elem].id); - return; - } + if (searchTitle) { + if (Tab.title.toLowerCase().match(input.toLowerCase())) { + document.getElementById(Tab.id).classList.add("filtered"); + document.getElementById(Tab.id).classList.add("selected_tab"); } - chrome.bookmarks.create({parentId: vertical_tabs_folderId, title: FolderName}, function(active_group_folderId_new){ - SlowlyBookmarkTabs(tabs_array, active_group_folderId_new.id); - }); - }); + } }); }); } +// sort tabs main function +// function SortTabs() { + // if ($(".tab").find(":visible:first")[0]){ + // chrome.tabs.query({windowId: vt.windowId}, function(tabs){ + // tabs.sort(function(tab_a, tab_b){ + // return SplitUrl(tab_a).localeCompare( SplitUrl(tab_b) ); + // }); + // var first_tabId; + // if ($(".selected:visible")[0]){ + // first_tabId = parseInt($(".selected:visible")[0].id); + // } else { + // first_tabId = parseInt($(".tab").find(":visible:first")[0].parentNode.id); + // } + // chrome.tabs.get(first_tabId, function(tab){ + // var new_index = tab.index; + // tabs.forEach(function(Tab){ + // // sort selected when more than 1 tab is selected + // if (($(".selected:visible").length > 1 && $("#"+Tab.id).is(":visible") && !Tab.pinned && $("#"+Tab.id).is(".selected")) || ($(".selected:visible").length < 2 && $("#"+Tab.id).is(":visible") && !Tab.pinned)){ + // chrome.tabs.move(Tab.id, {"index": new_index}); + // new_index++; + // } + // }); + // }); + // if (bg.opt.scroll_to_active){ + // setTimeout(function(){ + // ScrollTabList($(".active:visible")[0].id); + // },1000); + // } + // }); + // } +// } -// bookmark sub function -function SlowlyBookmarkTabs(tabs_array, group_folderId){ - if (tabs_array.length > 0){ - chrome.tabs.get(tabs_array[0], function(tab){ - chrome.bookmarks.search({url: tab.url}, function(list){ - tabs_array.splice(0, 1); - setTimeout(function(){ - SlowlyBookmarkTabs(tabs_array, group_folderId); - },10); - for (var elem in list){ - if (list[elem].parentId == group_folderId){ - bookmarkId = list[elem].id; - return; - } +// sort tabs sub function +// function SplitUrl(tab) { + // var tmp_url = new URL(tab.url); + // if (tmp_url.protocol != "http:"){ + // tmp_url.protocol == "http:"; + // } + // var url_parts = []; + // if (tab.pinned){ + // url_parts.push("#"+tab.index); + // } else { + // url_parts.push("~"); + // } + // var parts = tmp_url.host.split("."); + // parts.reverse(); + // if (parts.length > 1){ + // parts = parts.slice(1); + // } + // parts.join("."); + // url_parts.push(parts); + // url_parts.push(tab.title.toLowerCase()); + // return url_parts.join(" ! "); +// } + +function Bookmark(rootNode) { + let ToolbarId = browserId == "F" ? "toolbar_____" : "1"; + chrome.bookmarks.get(ToolbarId, function(list) { + chrome.bookmarks.search("TreeTabs", function(list) { + let TreeTabsId; + for (var elem in list) { + if (list[elem].parentId == ToolbarId) { + TreeTabsId = list[elem].id; + break; } - chrome.bookmarks.create({parentId: group_folderId, title: tab.title, url: tab.url}); - }); + } + if (TreeTabsId == undefined) { + chrome.bookmarks.create({parentId: ToolbarId, title: "TreeTabs"}, function(TreeTabsNew) { + TreeTabsId = TreeTabsNew.id; + }); + Bookmark(rootNode); + return; + } else { + if (rootNode.classList.contains("tab")) { + chrome.tabs.get(parseInt(rootNode.id), function(tab) { + if (tab) { + chrome.bookmarks.create({parentId: TreeTabsId, title: tab.title}, function(root) { + document.querySelectorAll("[id='"+rootNode.id+"'], [id='"+rootNode.id+"'] .tab").forEach(function(s){ + chrome.tabs.get(parseInt(s.id), function(tab){ + if (tab) { + chrome.bookmarks.create({parentId: root.id, title: tab.title, url: tab.url }); + } + }); + }); + }); + } + }); + } + + if (rootNode.classList.contains("folder") || rootNode.classList.contains("group")) { + let rootName = caption_noname_group; + if (rootNode.classList.contains("folder") && bgfolders[rootNode.id]) { + rootName = bgfolders[rootNode.id].name; + } + if (rootNode.classList.contains("group") && bggroups[rootNode.id]) { + rootName = bggroups[rootNode.id].name; + } + + chrome.bookmarks.create({parentId: TreeTabsId, title: rootName}, function(root) { + let foldersRefs = {}; + + let folders = document.querySelectorAll("#cf"+rootNode.id+" .folder"); + folders.forEach(function(s){ + if (bgfolders[s.id]) { + let ttId = s.id; + chrome.bookmarks.create({parentId: root.id, title: bgfolders[ttId].name}, function(Bkfolder) { + foldersRefs[ttId] = {ttid: ttId, id: Bkfolder.id, ttparent: bgfolders[ttId].parent, parent: root.id}; + + let elemInd = 0; + if (ttId == folders[folders.length-1].id) { + for (var elem in foldersRefs) { + let FolderTTId = foldersRefs[elem].ttid; + let BookmarkFolderId = foldersRefs[elem].id; + let TTParentId = foldersRefs[elem].ttparent; + if (foldersRefs[TTParentId]) { + foldersRefs[FolderTTId].parent = foldersRefs[TTParentId].id; + } + + elemInd++; + + if (elemInd == Object.keys(foldersRefs).length) { + elemInd = 0; + for (var elem in foldersRefs) { + let BookmarkFolderId = foldersRefs[elem].id; + let BookmarkFolderParentId = foldersRefs[elem].parent; + chrome.bookmarks.move(BookmarkFolderId, {parentId: BookmarkFolderParentId}, function(BkFinalfolder) { + document.querySelectorAll("#ct"+foldersRefs[elem].ttid+" .tab").forEach(function(s){ + chrome.tabs.get(parseInt(s.id), function(tab){ + if (tab) { + chrome.bookmarks.create({parentId: BkFinalfolder.id, title: tab.title, url: tab.url }); + } + }); + }); + + elemInd++; + + }); + } + } + } + } + }); + } + }); + + document.querySelectorAll("#ct"+rootNode.id+" .tab").forEach(function(s){ + chrome.tabs.get(parseInt(s.id), function(tab){ + if (tab) { + chrome.bookmarks.create({parentId: root.id, title: tab.title, url: tab.url }); + } + }); + }); + + }); + } + } }); - } + }); } \ No newline at end of file diff --git a/sidebar.html b/sidebar.html index bba730b..35b8311 100644 --- a/sidebar.html +++ b/sidebar.html @@ -23,36 +23,29 @@ + + + + + - -
-
+
-
-
-
-
-
-
+
+
+
-
-
- -
-
-
-
-
-
+
+
@@ -71,100 +64,82 @@
- -