Skip to content

Commit

Permalink
Refactor: move code around panel reopening into checkForReopenPanel()
Browse files Browse the repository at this point in the history
(#18)
  • Loading branch information
Infocatcher committed Nov 21, 2014
1 parent bc7ebd5 commit c1a6d93
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions downloadsPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,21 +205,8 @@ var downloadsPanel = {
},

panelClick: function(e) {
var trg = e.originalTarget;
// See chrome://browser/content/downloads/downloads.js, DownloadsView.onDownloadClick()
if(
e.button == 0 && (
!trg.hasAttribute("oncommand") // => goDoCommand("downloadsCmd_open")
&& this.dpt.da.getDlNode(trg)
&& prefs.get("reopenPanel.openFile")
|| trg.classList.contains("downloadButton")
&& trg.classList.contains("downloadShow")
&& prefs.get("reopenPanel.openContainingFolder")
)
) {
this.reopenPanel(e.view);
}

if(e.button == 0)
this.checkForReopenPanel(e);
if(e.button != 1 || !prefs.get("middleClickToRemoveFromPanel"))
return;
var dlController = this.dpt.da.getDlController(e.target);
Expand All @@ -228,6 +215,20 @@ var downloadsPanel = {
this.dpt.da.removeFromPanel(dlController, prefs.get("middleClickToRemoveFromPanel.clearHistory"));
this.dpt.stopEvent(e);
},
checkForReopenPanel: function(e) {
var trg = e.originalTarget;
if(
// See chrome://browser/content/downloads/downloads.js, DownloadsView.onDownloadClick()
!trg.hasAttribute("oncommand") // => goDoCommand("downloadsCmd_open")
&& this.dpt.da.getDlNode(trg)
&& prefs.get("reopenPanel.openFile")
|| trg.classList.contains("downloadButton")
&& trg.classList.contains("downloadShow")
&& prefs.get("reopenPanel.openContainingFolder")
) {
this.reopenPanel(e.view);
}
},
reopenPanel: function(window) {
window.setTimeout(function() {
var stopTime = Date.now() + prefs.get("reopenPanel.delayFallback");
Expand Down

0 comments on commit c1a6d93

Please sign in to comment.