Skip to content

Commit

Permalink
feat: new options & problems fixed
Browse files Browse the repository at this point in the history
 - change: refactor options data structure
 - change: change the style of options page
 - feat: add a new option 'titleFontSize' to allow user change the font size of list title (fixes cnwangjie#87)
 - feat: add 4 new options to allow user disable some feature to improve appearance (fixes cnwangjie#92)
  • Loading branch information
cnwangjie committed Jan 29, 2019
1 parent 75e6f4c commit 88400f6
Show file tree
Hide file tree
Showing 8 changed files with 213 additions and 100 deletions.
67 changes: 44 additions & 23 deletions src/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,78 +50,96 @@
"cmd_store_all_in_all_windows": {
"message": "Store all tabs in all windows"
},
"opt_desc_browserAction": {
"opt_name_browserAction": {
"message": "Behavior when icon is clicked"
},
"opt_desc_itemClickAction": {
"opt_name_itemClickAction": {
"message": "Behavior when item in a list is clicked"
},
"opt_desc_itemDisplay": {
"opt_name_itemDisplay": {
"message": "Contents of the items in a list"
},
"opt_desc_hideFavicon": {
"opt_name_hideFavicon": {
"message": "Hide favicon of items in the list"
},
"opt_desc_removeItemBtnPos": {
"opt_name_removeItemBtnPos": {
"message": "The position of remove item button"
},
"opt_desc_popupItemClickAction": {
"opt_name_popupItemClickAction": {
"message": "Behavior when item in simple list is clicked"
},
"opt_desc_defaultNightMode": {
"opt_name_defaultNightMode": {
"message": "Use night mode by default"
},
"opt_desc_fixedToolbar": {
"opt_name_fixedToolbar": {
"message": "Fixed toolbar"
},
"opt_desc_addHistory": {
"opt_name_addHistory": {
"message": "Add stored tab to history"
},
"opt_desc_ignorePinned": {
"opt_name_ignorePinned": {
"message": "Prevent store pinned tabs"
},
"opt_desc_pinNewList": {
"opt_name_pinNewList": {
"message": "Auto pin new list"
},
"opt_desc_pageContext": {
"opt_name_pageContext": {
"message": "Enable context menu for page"
},
"opt_desc_allContext": {
"opt_name_allContext": {
"message": "Enable context menu for all elements"
},
"opt_name_openTabListWhenNewTab": {
"message": "Open tab list when new tab"
},
"opt_desc_openTabListWhenNewTab": {
"message": "Always open tab list when clicking on the icon if current tab is a new tab. (Doesn't work if behavior is set to \"popup simple list\""
},
"opt_desc_syncOptions": {
"opt_name_syncOptions": {
"message": "Sync settings"
},
"opt_desc_syncList": {
"opt_name_syncList": {
"message": "Sync lists"
},
"opt_desc_useBoss": {
"opt_name_useBoss": {
"message": "Use better onetab sync server (unlimited storage)"
},
"opt_desc_alertRemoveList": {
"opt_name_alertRemoveList": {
"message": "Confirm to remove list"
},
"opt_desc_excludeIllegalURL": {
"opt_name_excludeIllegalURL": {
"message": "Exclude illegal URL like about:* or chrome://*"
},
"opt_desc_removeDuplicate": {
"opt_name_removeDuplicate": {
"message": "Remove duplicate item in a list"
},
"opt_desc_enableSearch": {
"opt_name_enableSearch": {
"message": "Enable search in the detail list page"
},
"opt_desc_openEnd": {
"opt_name_openEnd": {
"message": "When restore list open at the ending of tabs"
},
"opt_desc_openTabListNoTab": {
"opt_name_openTabListNoTab": {
"message": "Open the tab list when store all tabs"
},
"opt_desc_listsPerPage": {
"opt_name_listsPerPage": {
"message": "Number of lists per page"
},
"opt_name_titleFontSize": {
"message": "Font size of list title"
},
"opt_name_disableDynamicMenu": {
"message": "Disable dynamic menus update"
},
"opt_name_disableExpansion": {
"message": "Disable expansion in list page"
},
"opt_name_disableTransition": {
"message": "Disable all CSS transition animation"
},
"opt_name_disableSearch": {
"message": "Disable search feature"
},
"opt_label_popup": {
"message": "Popup simple list"
},
Expand Down Expand Up @@ -209,6 +227,9 @@
"ui_options_appearance": {
"message": "Appearance"
},
"ui_options_performance": {
"message": "Performance"
},
"ui_options_sync": {
"message": "Sync"
},
Expand Down
67 changes: 44 additions & 23 deletions src/_locales/zh_CN/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,78 +50,96 @@
"cmd_store_all_in_all_windows": {
"message": "保存所有窗口的所有标签页"
},
"opt_desc_browserAction": {
"opt_name_browserAction": {
"message": "图标被点击的行为"
},
"opt_desc_itemClickAction": {
"opt_name_itemClickAction": {
"message": "列表中的某一项被点击的行为"
},
"opt_desc_itemDisplay": {
"opt_name_itemDisplay": {
"message": "列表中的项显示的内容"
},
"opt_desc_hideFavicon": {
"opt_name_hideFavicon": {
"message": "列表中不显示图标"
},
"opt_desc_removeItemBtnPos": {
"opt_name_removeItemBtnPos": {
"message": "移除标签页的按钮位置"
},
"opt_desc_popupItemClickAction": {
"opt_name_popupItemClickAction": {
"message": "弹出列表中的项被点击的行为"
},
"opt_desc_defaultNightMode": {
"opt_name_defaultNightMode": {
"message": "默认使用夜间模式"
},
"opt_desc_fixedToolbar": {
"opt_name_fixedToolbar": {
"message": "固定顶部工具栏"
},
"opt_desc_addHistory": {
"opt_name_addHistory": {
"message": "保存的标签页添加到历史记录"
},
"opt_desc_ignorePinned": {
"opt_name_ignorePinned": {
"message": "不保存已固定的标签页"
},
"opt_desc_pinNewList": {
"opt_name_pinNewList": {
"message": "自动固定新的列表"
},
"opt_desc_pageContext": {
"opt_name_pageContext": {
"message": "出现在页面的右键菜单中"
},
"opt_desc_allContext": {
"opt_name_allContext": {
"message": "出现在所有元素的右键菜单中"
},
"opt_name_openTabListWhenNewTab": {
"message": "当新标签页时打开标签列表"
},
"opt_desc_openTabListWhenNewTab": {
"message": "当前页面为新标签页的时候点击图标时显示标签页列表 (不会覆盖弹出简易列表的行为)"
},
"opt_desc_syncOptions": {
"opt_name_syncOptions": {
"message": "同步设置"
},
"opt_desc_syncList": {
"opt_name_syncList": {
"message": "同步列表"
},
"opt_desc_useBoss": {
"opt_name_useBoss": {
"message": "使用better onetab同步服务(不限制保存空间)"
},
"opt_desc_alertRemoveList": {
"opt_name_alertRemoveList": {
"message": "删除列表时确认"
},
"opt_desc_excludeIllegalURL": {
"opt_name_excludeIllegalURL": {
"message": "排除非标准 URL,例如 about:* 和 chrome://*"
},
"opt_desc_removeDuplicate": {
"opt_name_removeDuplicate": {
"message": "列表中避免重复"
},
"opt_desc_enableSearch": {
"opt_name_enableSearch": {
"message": "详细列表中启用搜索功能"
},
"opt_desc_openEnd": {
"opt_name_openEnd": {
"message": "恢复列表时标签页在末尾打开"
},
"opt_desc_openTabListNoTab": {
"opt_name_openTabListNoTab": {
"message": "当储存所有标签时打开标签列表"
},
"opt_desc_listsPerPage": {
"opt_name_listsPerPage": {
"message": "每页的列表数量"
},
"opt_name_titleFontSize": {
"message": "列表标题的字体大小"
},
"opt_name_disableDynamicMenu": {
"message": "禁用动态更新菜单"
},
"opt_name_disableExpansion": {
"message": "禁用可展开的列表"
},
"opt_name_disableTransition": {
"message": "禁用所有 CSS 过渡动画"
},
"opt_name_disableSearch": {
"message": "禁用搜索功能"
},
"opt_label_popup": {
"message": "弹出简单列表"
},
Expand Down Expand Up @@ -209,6 +227,9 @@
"ui_options_appearance": {
"message": "外观"
},
"ui_options_performance": {
"message": "性能"
},
"ui_options_sync": {
"message": "同步"
},
Expand Down
11 changes: 7 additions & 4 deletions src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ const setupContextMenus = _.debounce(async ({pageContext, allContext}) => {
const lists = await storage.getLists()
const createMenus = async (obj, parent) => {
if (obj === menus.STORE_TO_TITLED_LIST) {
if (window.opts.disableDynamicMenu) return
for (let listIndex = 0; listIndex < lists.length; listIndex += 1) {
if (!lists[listIndex].title) continue
const prop = {
Expand Down Expand Up @@ -223,7 +224,7 @@ const init = async () => {
console.debug('options changed', changes)
Object.assign(window.opts, changes)
if (changes.browserAction) updateBrowserAction(changes.browserAction)
if (('pageContext' in changes) || ('allContext' in changes)) await setupContextMenus(changes)
if (['pageContext', 'allContext', 'disableDynamicMenu'].some(k => k in changes)) await setupContextMenus(changes)
await browser.runtime.sendMessage({optionsChangeHandledStatus: 'success'})
if (PRODUCTION) Object.keys(changes).map(key => ga('send', 'event', 'Options changed', key, changes[key]))
}
Expand Down Expand Up @@ -284,16 +285,18 @@ const init = async () => {
browser.browserAction.onClicked.addListener(action => window.browswerActionClickedHandler(action))
browser.contextMenus.onClicked.addListener(info => window.contextMenusClickedHandler(info))
browser.tabs.onActivated.addListener(_.debounce(activeInfo => {
if (window.opts.disableDynamicMenu) return
window.coverBrowserAction(activeInfo)
dynamicDisableMenu(activeInfo)
}, 200))
browser.storage.onChanged.addListener(async changes => {
console.log(changes)
browser.storage.onChanged.addListener(changes => {
console.debug('[storage changed]', changes)
if (changes.boss_token) {
window.boss_token = changes.boss_token
}
if (changes.lists) {
setupContextMenus(await storage.getOptions())
if (window.opts.disableDynamicMenu) return
setupContextMenus(window.opts)
}
})
await migrate()
Expand Down
Loading

0 comments on commit 88400f6

Please sign in to comment.