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 7, 2020
2 parents 914f165 + a510ba5 commit ddff1de
Show file tree
Hide file tree
Showing 33 changed files with 409 additions and 151 deletions.
11 changes: 9 additions & 2 deletions addon/actions/misc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
* Handle click on browser-action button
*/
function initToolbarButton() {
browser.browserAction.onClicked.addListener(async () => {
browser.sidebarAction.open()
createSettingsMenu()

browser.browserAction.onClicked.addListener(async (_, info) => {
if (info && info.button === 1) return browser.runtime.openOptionsPage()
else browser.sidebarAction.open()
})
}

Expand Down Expand Up @@ -35,10 +38,14 @@ async function loadPermissions() {

function onMenuHidden() {
browser.menus.removeAll()
createSettingsMenu()
}

function createSettingsMenu() {
browser.menus.create({
id: 'open_settings',
title: 'Open settings',
icons: { '16': 'assets/logo-native.svg' },
onclick: () => browser.runtime.openOptionsPage(),
contexts: ['browser_action'],
})
Expand Down
9 changes: 9 additions & 0 deletions addon/actions/snapshots.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,15 @@ async function createSnapshot() {
lastSnapTime: currentSnapshot.time,
})

if (this.settings.snapNotify) {
let win = await browser.windows.getCurrent({ populate: false })
browser.runtime.sendMessage({
windowId: win.id,
instanceType: 'sidebar',
action: 'notifyAboutNewSnapshot',
})
}

return currentSnapshot
}
function createSnapshotDebounced(delay = 750) {
Expand Down
5 changes: 3 additions & 2 deletions addon/background.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Actions, { injectInActions } from './actions.js'
import { DEFAULT_SETTINGS } from './defaults.js'

void (async function main() {
const state = injectInActions()
Expand All @@ -22,8 +23,8 @@ void (async function main() {
await Actions.loadContainers()

// Load settings
let { settings } = await browser.storage.local.get({ settings: null })
state.settings = settings ? settings : {}
let { settings } = await browser.storage.local.get({ settings: {} })
state.settings = Utils.normalizeObject(settings, DEFAULT_SETTINGS)

await Actions.loadTabs(state.windows, state.tabsMap)
await Actions.backupTabsData()
Expand Down
35 changes: 8 additions & 27 deletions addon/defaults.js
Original file line number Diff line number Diff line change
@@ -1,42 +1,21 @@
import { translate } from './locales/dict.js'

// prettier-ignore
export const SETTINGS_OPTIONS = {
autoHideCtxMenuOpts: [250, 500, 1000, 'none'],
navMidClickActionOpts: ['rm_all', 'none'],
groupLayoutOpts: ['grid', 'list'],
scrollThroughTabsOpts: ['panel', 'global', 'none'],
discardFoldedDelayUnitOpts: ['sec', 'min'],
tabDoubleClickOpts: [
'reload',
'duplicate',
'pin',
'mute',
'clear_cookies',
'exp',
'new_after',
'new_child',
'close',
'none',
'reload', 'duplicate', 'pin', 'mute', 'clear_cookies', 'exp', 'new_after', 'new_child',
'close', 'none',
],
tabLongLeftClickOpts: [
'reload',
'duplicate',
'pin',
'mute',
'clear_cookies',
'new_after',
'new_child',
'none',
'reload', 'duplicate', 'pin', 'mute', 'clear_cookies', 'new_after', 'new_child', 'none',
],
tabLongRightClickOpts: [
'reload',
'duplicate',
'pin',
'mute',
'clear_cookies',
'new_after',
'new_child',
'none',
'reload', 'duplicate', 'pin', 'mute', 'clear_cookies', 'new_after', 'new_child', 'none',
],
tabsPanelLeftClickActionOpts: ['prev', 'expand', 'parent', 'none'],
tabsPanelDoubleClickActionOpts: ['collapse', 'tab', 'none'],
Expand All @@ -59,7 +38,7 @@ export const SETTINGS_OPTIONS = {
midClickBookmarkOpts: ['open_new_tab', 'edit', 'delete'],
warnOnMultiTabCloseOpts: ['any', 'collapsed', 'none'],
warnOnMultiBookmarkDeleteOpts: ['any', 'collapsed', 'none'],
navBarLayoutOpts: ['horizontal', 'vertical'],
navBarLayoutOpts: ['horizontal', 'vertical', 'hidden'],
stateStorageOpts: ['global', 'session'],
autoFoldTabsExceptOpts: [1, 2, 3, 4, 5, 'none'],
}
Expand Down Expand Up @@ -94,6 +73,7 @@ export const DEFAULT_SETTINGS = {
activateLastTabOnPanelSwitching: true,
skipEmptyPanels: false,
showTabRmBtn: true,
showTabCtx: true,
hideInact: false,
activateAfterClosing: 'next',
activateAfterClosingPrevRule: 'visible',
Expand Down Expand Up @@ -153,6 +133,7 @@ export const DEFAULT_SETTINGS = {
groupCSS: false,

// Snapshots
snapNotify: true,
snapInterval: 0,
snapIntervalUnit: 'min',
snapLimit: 0,
Expand Down
3 changes: 3 additions & 0 deletions addon/locales/en.notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ export default {
message: [' bookmark was removed', ' bookmarks were removed'],
plur: [1],
},
'notif.bookmarks_sort': { message: 'Sorting bookmarks...' },
'notif.snapshot_created': { message: 'Snapshot created' },
'notif.view_snapshot': { message: 'View' },
}
4 changes: 4 additions & 0 deletions addon/locales/en.settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export default {
'settings.nav_bar_layout': { message: 'Layout' },
'settings.nav_bar_layout_horizontal': { message: 'horizontal' },
'settings.nav_bar_layout_vertical': { message: 'vertical' },
'settings.nav_bar_layout_hidden': { message: 'hidden' },
'settings.nav_bar_inline': { message: 'Show navigation bar in one line' },
'settings.hide_settings_btn': { message: 'Hide settings button' },
'settings.hide_add_btn': { message: 'Hide "Create panel" button' },
Expand Down Expand Up @@ -100,6 +101,7 @@ export default {
},
'settings.skip_empty_panels': { message: 'Skip empty panels on switching' },
'settings.show_tab_rm_btn': { message: 'Show close button on mouse hover' },
'settings.show_tab_ctx': { message: 'Show color mark of container' },
'settings.hide_inactive_panel_tabs': { message: 'Hide tabs of inactive panels' },
'settings.activate_after_closing': { message: 'After closing current tab activate' },
'settings.activate_after_closing_next': { message: 'next tab' },
Expand Down Expand Up @@ -236,6 +238,7 @@ export default {

// --- Snapshots
'settings.snapshots_title': { message: 'Snapshots' },
'settings.snap_notify': { message: 'Show notification after snapshot creation' },
'settings.snap_interval': { message: 'Auto-snapshots interval' },
'settings.snap_interval_min': { message: ['minute', 'minutes'], plur: [1] },
'settings.snap_interval_hr': { message: ['hour', 'hours'], plur: [1] },
Expand Down Expand Up @@ -289,6 +292,7 @@ export default {
// --- Keybindings
'settings.kb_title': { message: 'Keybindings' },
'settings.reset_kb': { message: 'Reset Keybindings' },
'settings.toggle_kb': { message: 'Enable/Disable Keybindings' },

// --- Permissions
'settings.permissions_title': { message: 'Permissions' },
Expand Down
12 changes: 12 additions & 0 deletions addon/locales/en.styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,16 @@ export default {

'styles.css_sidebar': { message: 'Sidebar' },
'styles.css_group': { message: 'Group page' },
'styles.css_placeholder': { message: 'Write custom CSS here...' },
'styles.css_selectors_instruction': {
message: `NOTE: To get currently available css-selectors use debugger:
- Enter "about:debugging" in the URL bar
- In the left-hand menu, click This Firefox (or This Nightly)
- Click Inspect next to Sidebery extension
- Select frame to inspect
- Click on the rectangular icon (with three sections) in top-right area of the debugger page
- Select "/sidebar/index.html" for sidebar frame
- Select "/group/group.html" for group page frame
- Browse "Inspector" tab`,
},
}
3 changes: 3 additions & 0 deletions addon/locales/ru.notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ export default {
message: [' закладка была удалена', ' закладки было удалено', ' закладок было удалено'],
plur: [/^(1|(\d*?)[^1]1)$/, /^([234]|(\d*?)[^1][234])$/],
},
'notif.bookmarks_sort': { message: 'Сортировка закладок...' },
'notif.snapshot_created': { message: 'Снепшот создан' },
'notif.view_snapshot': { message: 'Посмотреть' },
}
4 changes: 4 additions & 0 deletions addon/locales/ru.settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export default {
'settings.nav_bar_layout': { message: 'Расположение' },
'settings.nav_bar_layout_horizontal': { message: 'горизонтальное' },
'settings.nav_bar_layout_vertical': { message: 'вертикальное' },
'settings.nav_bar_layout_hidden': { message: 'скрытое' },
'settings.nav_bar_inline': { message: 'В одну строку' },
'settings.hide_settings_btn': { message: 'Скрывать кнопку "Настройки"' },
'settings.hide_add_btn': { message: 'Скрывать кнопку "Создать панель"' },
Expand Down Expand Up @@ -101,6 +102,7 @@ export default {
},
'settings.skip_empty_panels': { message: 'Пропускать пустые контейнеры при переключении' },
'settings.show_tab_rm_btn': { message: 'Показывать кнопку закрытия таба при наведении курсора' },
'settings.show_tab_ctx': { message: 'Показывать цветовую метку контейнера' },
'settings.hide_inactive_panel_tabs': { message: 'Скрывать табы неактивных панелей' },
'settings.activate_after_closing': { message: 'После закрытия текущей вкладки активировать' },
'settings.activate_after_closing_next': { message: 'следующую' },
Expand Down Expand Up @@ -255,6 +257,7 @@ export default {

// --- Snapshots
'settings.snapshots_title': { message: 'Снепшоты' },
'settings.snap_notify': { message: 'Показать уведомление после создания снепшота' },
'settings.snap_interval': { message: 'Интервал авто-снепшотов' },
'settings.snap_interval_min': {
message: ['минута', 'минуты', 'минут'],
Expand Down Expand Up @@ -330,6 +333,7 @@ export default {
// --- Keybindings
'settings.kb_title': { message: 'Клавиши' },
'settings.reset_kb': { message: 'Сбросить клав. настройки' },
'settings.toggle_kb': { message: 'Включить / отключить сочетания клавиш' },

// --- Permissions
'settings.permissions_title': { message: 'Разрешения' },
Expand Down
12 changes: 12 additions & 0 deletions addon/locales/ru.styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,16 @@ export default {

'styles.css_sidebar': { message: 'Боковая панель' },
'styles.css_group': { message: 'Групповая страница' },
'styles.css_placeholder': { message: 'Write custom CSS here...' },
'styles.css_selectors_instruction': {
message: `NOTE: To get currently available css-selectors use debugger:
- Enter "about:debugging" in the URL bar
- In the left-hand menu, click This Firefox (or This Nightly)
- Click Inspect next to Sidebery extension
- Select frame to inspect
- Click on the rectangular icon (with three sections) in top-right area of the debugger page
- Select "/sidebar/index.html" for sidebar frame
- Select "/group/group.html" for group page frame
- Browse "Inspector" tab`,
},
}
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.0.5",
"version": "4.1.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.0.5",
"version": "4.1.0",
"description": "Manage your tabs and bookmarks in sidebar",
"main": "index.js",
"scripts": {
Expand Down
13 changes: 12 additions & 1 deletion src/actions/keybindings.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,18 @@
* Load keybindings
*/
async function loadKeybindings() {
let commands = await browser.commands.getAll()
let [commands, storage] = await Promise.all([
browser.commands.getAll(),
browser.storage.local.get({ disabledKeybindings: {} }),
])

this.state.kbMap = {}

for (let k of commands) {
k.active = !storage.disabledKeybindings[k.name]
this.state.kbMap[k.name] = k
}

this.state.keybindings = commands
}

Expand Down
12 changes: 12 additions & 0 deletions src/page.settings/actions/keybindings.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ async function updateKeybinding(name, shortcut) {
await browser.commands.update({ name, shortcut })
}

/**
* Save keybindings
*/
async function saveKeybindings() {
let disabledKeybindings = {}
for (let k of this.state.keybindings) {
if (!k.active) disabledKeybindings[k.name] = true
}
await browser.storage.local.set({ disabledKeybindings })
}

/**
* Reset addon's keybindings
*/
Expand All @@ -24,5 +35,6 @@ export default {
...CommonActions,

updateKeybinding,
saveKeybindings,
resetKeybindings,
}
7 changes: 6 additions & 1 deletion src/page.settings/components/styles-editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -523,10 +523,15 @@
textarea.editor(
ref="cssEditor"
v-model="customCSS"
autocomplete="off"
autocorrect="off"
autocapitalize="off"
spellcheck="false"
@input="onInput"
@keydown.tab.prevent=""
@change="applyCssDebounced")
.placeholder(:data-hidden="!!customCSS") CSS...
.placeholder(:data-hidden="!!customCSS") {{t('styles.css_placeholder')}}
.placeholder-note(:data-hidden="!!customCSS") {{t('styles.css_selectors_instruction')}}
</template>

<script>
Expand Down
Loading

0 comments on commit ddff1de

Please sign in to comment.