Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
mbnuqw committed Jan 11, 2020
2 parents 526373a + 4c12e08 commit 9d64901
Show file tree
Hide file tree
Showing 18 changed files with 105 additions and 63 deletions.
17 changes: 8 additions & 9 deletions addon/actions/snapshots.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,14 @@ async function createSnapshot() {
const items = []

for (let tab of window.tabs) {
items.push({
id: tab.id,
pinned: tab.pinned,
url: tab.url,
title: tab.title,
lvl: tab.lvl,
ctr: tab.cookieStoreId,
panel: tab.panelId,
})
let item = { id: tab.id, url: tab.url, title: tab.title }

if (tab.pinned) item.pinned = true
if (tab.cookieStoreId !== DEFAULT_CTX_ID) item.ctr = tab.cookieStoreId
if (tab.panelId !== DEFAULT_CTX_ID) item.panel = tab.panelId
if (tab.lvl > 0) item.lvl = tab.lvl

items.push(item)
}

windows[windowId] = { items }
Expand Down
4 changes: 2 additions & 2 deletions addon/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ export const SETTINGS_OPTIONS = {
snapLimitUnitOpts: ['snap', 'kb', 'day'],
panelTypeOpts: ['tabs', 'ctx'],
moveNewTabPinOpts: ['start', 'end', 'none'],
moveNewTabParentOpts: ['sibling', 'first_child', 'last_child', 'start', 'end', 'none'],
moveNewTabOpts: ['start', 'end', 'after', 'first_child', 'last_child', 'none'],
moveNewTabParentOpts: ['before', 'sibling', 'first_child', 'last_child', 'start', 'end', 'none'],
moveNewTabOpts: ['start', 'end', 'before', 'after', 'first_child', 'last_child', 'none'],
midClickBookmarkOpts: ['open_new_tab', 'edit', 'delete'],
warnOnMultiTabCloseOpts: ['any', 'collapsed', 'none'],
warnOnMultiBookmarkDeleteOpts: ['any', 'collapsed', 'none'],
Expand Down
8 changes: 5 additions & 3 deletions addon/locales/en.settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default {
'settings.nav_settings_containers': { message: 'Containers' },
'settings.nav_settings_panels': { message: 'Panels' },
'settings.nav_settings_tabs': { message: 'Tabs' },
'settings.nav_settings_new_tab_position': { message: 'New tab position' },
'settings.nav_settings_new_tab_position': { message: 'Position of new tab' },
'settings.nav_settings_pinned_tabs': { message: 'Pinned tabs' },
'settings.nav_settings_tabs_tree': { message: 'Tabs tree' },
'settings.nav_settings_bookmarks': { message: 'Bookmarks' },
Expand Down Expand Up @@ -124,13 +124,14 @@ export default {
},

// --- New tab position
'settings.new_tab_position': { message: 'New tab position' },
'settings.new_tab_position': { message: 'Position of new tab' },
'settings.move_new_tab_pin': { message: 'Place new tab opened from pinned tab' },
'settings.move_new_tab_pin_start': { message: 'panel start' },
'settings.move_new_tab_pin_end': { message: 'panel end' },
'settings.move_new_tab_pin_none': { message: 'none' },
'settings.move_new_tab_parent': { message: 'Place new tab opened from another tab' },
'settings.move_new_tab_parent_sibling': { message: 'sibling' },
'settings.move_new_tab_parent_before': { message: 'before parent' },
'settings.move_new_tab_parent_sibling': { message: 'after parent' },
'settings.move_new_tab_parent_first_child': { message: 'first child' },
'settings.move_new_tab_parent_last_child': { message: 'last child' },
'settings.move_new_tab_parent_start': { message: 'panel start' },
Expand All @@ -140,6 +141,7 @@ export default {
'settings.move_new_tab': { message: 'Place new tab (for the other cases)' },
'settings.move_new_tab_start': { message: 'panel start' },
'settings.move_new_tab_end': { message: 'panel end' },
'settings.move_new_tab_before': { message: 'before active tab' },
'settings.move_new_tab_after': { message: 'after active tab' },
'settings.move_new_tab_first_child': { message: 'first child of active tab' },
'settings.move_new_tab_last_child': { message: 'last child of active tab' },
Expand Down
6 changes: 4 additions & 2 deletions addon/locales/ru.settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ export default {
'settings.move_new_tab_pin_end': { message: 'конец пенели' },
'settings.move_new_tab_pin_none': { message: 'выкл' },
'settings.move_new_tab_parent': { message: 'Открытые из другой вкладки' },
'settings.move_new_tab_parent_sibling': { message: 'по соседству' },
'settings.move_new_tab_parent_before': { message: 'перед родительской' },
'settings.move_new_tab_parent_sibling': { message: 'после родительской' },
'settings.move_new_tab_parent_first_child': { message: 'первая дочерняя' },
'settings.move_new_tab_parent_last_child': { message: 'последняя дочерняя' },
'settings.move_new_tab_parent_start': { message: 'начало панели' },
Expand All @@ -143,7 +144,8 @@ export default {
'settings.move_new_tab': { message: 'Для остальных случаев' },
'settings.move_new_tab_start': { message: 'начало панели' },
'settings.move_new_tab_end': { message: 'конец пенели' },
'settings.move_new_tab_after': { message: 'после активной вкладки' },
'settings.move_new_tab_before': { message: 'перед активной вкладкой' },
'settings.move_new_tab_after': { message: 'после активной вкладкой' },
'settings.move_new_tab_first_child': { message: 'первая дочерняя вкладка активной' },
'settings.move_new_tab_last_child': { message: 'последняя дочерняя вкладка активной' },
'settings.move_new_tab_none': { message: 'выкл' },
Expand Down
2 changes: 1 addition & 1 deletion addon/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"author": "mbnuqw",
"name": "__MSG_ExtName__",
"version": "4.1.2",
"version": "4.2.0",
"default_locale": "en",
"description": "__MSG_ExtDesc__",
"homepage_url": "https://github.com/mbnuqw/sidebery",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sidebery",
"version": "4.1.2",
"version": "4.2.0",
"description": "Manage your tabs and bookmarks in sidebar",
"main": "index.js",
"scripts": {
Expand Down
4 changes: 4 additions & 0 deletions src/sidebar/actions/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ const xmlSerializer = new XMLSerializer()
*/
async function openCtxMenu(type, x, y) {
if (!this.state.selected.length) return
if (this.state.tabLongClickFired) {
this.state.tabLongClickFired = false
return
}
if (!type) return

let nodeType,
Expand Down
19 changes: 14 additions & 5 deletions src/sidebar/actions/misc.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,12 @@ function resetSelection() {
let id = this.state.selected[0]
if (typeof id === 'number') {
for (let id of this.state.selected) {
this.state.tabsMap[id].sel = false
if (this.state.tabsMap[id]) this.state.tabsMap[id].sel = false
}
if (this.state.nativeHighlight) this.actions.updateHighlightedTabs(120)
} else if (typeof id === 'string') {
for (let id of this.state.selected) {
this.state.bookmarksMap[id].sel = false
if (this.state.bookmarksMap[id]) this.state.bookmarksMap[id].sel = false
}
}
this.state.selected = []
Expand Down Expand Up @@ -208,6 +208,17 @@ function blockCtxMenu() {
}, 500)
}

/**
* Reset long-click action fired flag
*/
function resetLongClickLock() {
if (this.state.tabLongClickFired) {
setTimeout(() => {
this.state.tabLongClickFired = false
}, 120)
}
}

/**
* Start multi selection
*/
Expand Down Expand Up @@ -296,9 +307,6 @@ function askNewBookmarkFolder(defaultValue) {
if (!bookmarksPanel) res(defaultValue)

this.state.panelIndex = bookmarksPanel.index

if (defaultValue !== undefined) this.actions.selectItem(defaultValue)

this.state.selectBookmarkFolder = {
id: '',
ok: () => {
Expand Down Expand Up @@ -373,6 +381,7 @@ export default {
updateSidebarWidth,
blockWheel,
blockCtxMenu,
resetLongClickLock,
startMultiSelection,
stopMultiSelection,
confirm,
Expand Down
27 changes: 19 additions & 8 deletions src/sidebar/actions/tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ async function loadTabsFromInlineData(tabs, dataTabIndex) {
}

let secondTab = tabs[dataTabIndex + 1]
if (!secondTab) secondTab = tabs[dataTabIndex - 1]
if (!secondTab) return this.actions.updatePanelsTabs()

await browser.tabs.update(secondTab.id, { active: true })
Expand Down Expand Up @@ -978,7 +979,9 @@ async function moveTabsToNewWin(tabIds, incognito = false) {
if (toMove.includes(id)) continue
tabs.push(tab)
toMove.push(id)
tabsInfo.push({ lvl: tab.lvl, panelId: tab.panelId })
let info = { lvl: tab.lvl, panelId: tab.panelId }
if (tab.pinned) info.pinned = true
tabsInfo.push(info)
if (tab.active) activeTab = tab
if (tab.folded) {
for (let i = tab.index + 1; i < this.state.tabs.length; i++) {
Expand Down Expand Up @@ -1009,12 +1012,9 @@ async function moveTabsToNewWin(tabIds, incognito = false) {
let index = 1
for (let tab of tabs) {
if (incognito === this.state.private) {
moving.push(
browser.tabs.move(tab.id, {
windowId: win.id,
index: index++,
})
)
let conf = { windowId: win.id }
conf.index = tab.pinned ? 0 : index++
moving.push(browser.tabs.move(tab.id, conf))
} else {
let conf = {
windowId: win.id,
Expand Down Expand Up @@ -2076,7 +2076,10 @@ function getPanelForNewTab(tab) {
}
}

// If position of new tab should be related with active one
// find the panel of active tab
let actTabRel =
this.state.moveNewTab === 'before' ||
this.state.moveNewTab === 'after' ||
this.state.moveNewTab === 'first_child' ||
this.state.moveNewTab === 'last_child'
Expand Down Expand Up @@ -2115,6 +2118,7 @@ function getIndexForNewTab(panel, tab) {

// Place new tab opened from another tab
if (parent && !parent.pinned && parent.panelId === panel.id) {
if (this.state.moveNewTabParent === 'before') return parent.index
if (this.state.moveNewTabParent === 'sibling' || this.state.moveNewTabParent === 'last_child') {
let t
let index = parent.index + 1
Expand All @@ -2133,6 +2137,11 @@ function getIndexForNewTab(panel, tab) {
// Place new tab (for the other cases)
if (this.state.moveNewTab === 'start') return panel.startIndex
if (this.state.moveNewTab === 'end') return endIndex
if (this.state.moveNewTab === 'before') {
if (!activeTab || activeTab.panelId !== panel.id) return endIndex
else if (activeTab.pinned) return panel.startIndex
else return activeTab.index
}
if (this.state.moveNewTab === 'after') {
if (!activeTab || activeTab.panelId !== panel.id) {
return endIndex
Expand Down Expand Up @@ -2184,6 +2193,7 @@ function getParentForNewTab(panel, openerTabId) {

// Place new tab opened from another tab
if (parent && !parent.pinned && parent.panelId === panel.id) {
if (this.state.moveNewTabParent === 'before') return parent.parentId
if (this.state.moveNewTabParent === 'sibling') return parent.parentId
if (this.state.moveNewTabParent === 'first_child') return openerTabId
if (this.state.moveNewTabParent === 'last_child') return openerTabId
Expand All @@ -2196,7 +2206,8 @@ function getParentForNewTab(panel, openerTabId) {
if (this.state.moveNewTab === 'start') return
if (this.state.moveNewTab === 'end') return
if (activeTab && activeTab.panelId === panel.id && !activeTab.pinned) {
if (this.state.moveNewTab === 'after') return activeTab.parentId
if (this.state.moveNewTab === 'before') return activeTab.parentId
else if (this.state.moveNewTab === 'after') return activeTab.parentId
else if (this.state.moveNewTab === 'first_child') return activeTab.id
else if (this.state.moveNewTab === 'last_child') return activeTab.id
}
Expand Down
1 change: 1 addition & 0 deletions src/sidebar/components/bookmark.vue
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ export default {
*/
onMouseUp(e) {
if (e.button === 0) {
if (State.selectBookmarkFolder) return
if (e.ctrlKey || e.shiftKey) return
if (State.selected.length && !this.node.sel) {
Expand Down
22 changes: 9 additions & 13 deletions src/sidebar/components/pinned-tab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ export default {
}
// Long-click action
this.longClickActionLeftFired = false
this.longClickActionLeft = setTimeout(() => {
if (State.dragNodes) return
let llc = State.tabLongLeftClick
Expand All @@ -169,7 +168,7 @@ export default {
if (llc === 'mute') Actions.remuteTabs([this.tab.id])
if (llc === 'clear_cookies') Actions.clearTabsCookies([this.tab.id])
if (llc === 'new_after') Actions.createTabAfter(this.tab.id)
if (llc !== 'none') this.longClickActionLeftFired = true
if (llc !== 'none') State.tabLongClickFired = true
this.longClickActionLeft = null
}, 300)
},
Expand All @@ -192,7 +191,6 @@ export default {
}
// Long-click action
this.longClickActionRightFired = false
this.longClickActionRight = setTimeout(() => {
Actions.stopMultiSelection()
let lrc = State.tabLongRightClick
Expand All @@ -202,7 +200,7 @@ export default {
if (lrc === 'mute') Actions.remuteTabs([this.tab.id])
if (lrc === 'clear_cookies') Actions.clearTabsCookies([this.tab.id])
if (lrc === 'new_after') Actions.createTabAfter(this.tab.id)
if (lrc !== 'none') this.longClickActionRightFired = true
if (lrc !== 'none') State.tabLongClickFired = true
this.longClickActionRight = null
}, 300)
},
Expand All @@ -211,13 +209,10 @@ export default {
* Handle mouseup event
*/
onMouseUp(e) {
if (State.tabLongClickFired) return Actions.resetLongClickLock()
if (e.button === 0) {
if (
(State.selected.length || State.activateOnMouseUp) &&
!this.longClickActionLeftFired &&
!e.ctrlKey &&
!e.shiftKey
) {
if ((State.selected.length || State.activateOnMouseUp) && !e.ctrlKey && !e.shiftKey) {
browser.tabs.update(this.tab.id, { active: true })
}
if (this.longClickActionLeft) {
Expand All @@ -233,18 +228,19 @@ export default {
if (e.ctrlKey || e.shiftKey) return
Actions.stopMultiSelection()
if (!State.ctxMenuNative && !this.longClickActionRightFired) {
if (!State.ctxMenuNative) {
Actions.selectItem(this.tab.id)
Actions.openCtxMenu('tab', e.clientX, e.clientY)
}
if (!State.ctxMenuNative) Actions.openCtxMenu('tab', e.clientX, e.clientY)
}
},
/**
* Handle context menu
*/
onCtxMenu(e) {
if (this.longClickActionRightFired || !State.ctxMenuNative || e.ctrlKey || e.shiftKey) {
if (State.tabLongClickFired || !State.ctxMenuNative || e.ctrlKey || e.shiftKey) {
State.tabLongClickFired = false
e.stopPropagation()
e.preventDefault()
return
Expand Down
17 changes: 15 additions & 2 deletions src/sidebar/components/select-bookmarks-folder-bar.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<template lang="pug">
.SelectBookmarksFolderBar(v-if="$store.state.selectBookmarkFolder")
h2 Select folder
.folder-title {{folderName}}
.folder-title(
:data-wrong="wrongValueAnimation"
@animationend="onAnimationEnd") {{folderName}}
.ctrls
.btn(@click="onSelectFolderOk") Ok
.btn.-warn(@click="onSelectFolderCancel") Cancel
Expand All @@ -12,7 +14,9 @@ import State from '../store/state'
export default {
data() {
return {}
return {
wrongValueAnimation: false,
}
},
computed: {
Expand All @@ -28,12 +32,21 @@ export default {
methods: {
onSelectFolderOk() {
if (!State.selectBookmarkFolder.id) return this.error()
if (State.selectBookmarkFolder.ok) State.selectBookmarkFolder.ok()
},
onSelectFolderCancel() {
if (State.selectBookmarkFolder.cancel) State.selectBookmarkFolder.cancel()
},
error() {
this.wrongValueAnimation = true
},
onAnimationEnd() {
this.wrongValueAnimation = false
},
},
}
</script>
Loading

0 comments on commit 9d64901

Please sign in to comment.