Skip to content

Commit

Permalink
Add option to close tabs marked for saving
Browse files Browse the repository at this point in the history
  • Loading branch information
gyng committed Feb 2, 2019
1 parent b392c0e commit b6f6669
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

* Add option to always prefer links when downloading from pages that match a regex list of URLs (#100)
* Add notification option for when a link is downloaded instead of the source
* Add option to close tabs marked for saving (FF, #68)

# 3.3.0

Expand Down
4 changes: 4 additions & 0 deletions _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -593,5 +593,9 @@

"o_cNotifyLinkPreferred": {
"message": "Show notification when a link was downloaded instead of the source"
},

"o_cCloseTabOnSave": {
"message": "Close tabs marked for saving"
}
}
9 changes: 8 additions & 1 deletion src/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ const Menus = {
}

const opts = {
currentTab: t, // Global
currentTab: t, // Global,
linkText: t.title,
now: new Date(),
pageUrl: t.url,
Expand All @@ -577,6 +577,13 @@ const Menus = {
};

Download.renameAndDownload(state);

// TODO: Store tabs marked for saving and close only on successful save
if (options.closeTabOnSave) {
window.setTimeout(() => {
browser.tabs.remove(t.id);
}, timeoutInterval);
}
}, timeoutInterval * i);
});
});
Expand Down
1 change: 1 addition & 0 deletions src/option.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ const OptionsManagement = {
{ name: "truncateLength", type: T.VALUE, default: 240 },
{ name: "fetchViaContent", type: T.BOOL, default: false },
{ name: "tabEnabled", type: T.BOOL, default: false },
{ name: "closeTabOnSave", type: T.BOOL, default: false },
{ name: "setRefererHeader", type: T.BOOL, default: false },
{
name: "setRefererHeaderFilter",
Expand Down
15 changes: 12 additions & 3 deletions src/options/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,15 @@ <h3>__MSG_o_sBehavior__</h3>
id="tabEnabled"
class="chrome-disabled"
/>__MSG_o_cSaveTabstrip__ <span class="badge">Firefox</span>
<div class="caption caption-line">__MSG_o_cSaveTabstripHelp__</div>
<div class="caption-line">
<label>
<input
type="checkbox"
id="closeTabOnSave"
/>__MSG_o_cCloseTabOnSave__
</label>
<div class="caption">__MSG_o_cSaveTabstripHelp__</div>
</div>
</label>

<label>
Expand Down Expand Up @@ -525,8 +533,9 @@ <h2 id="section-notifications">__MSG_o_sNotifications__</h2>
</label>

<label>
<input type="checkbox" id="notifyOnLinkPreferred" /> __MSG_o_cNotifyLinkPreferred__
</label>
<input type="checkbox" id="notifyOnLinkPreferred" />
__MSG_o_cNotifyLinkPreferred__
</label>

<label>
__MSG_o_cNotifyCloseAfter__
Expand Down

0 comments on commit b6f6669

Please sign in to comment.