Skip to content

Commit

Permalink
Merge pull request #2579 from Defman21/pr/fix-2507
Browse files Browse the repository at this point in the history
Commando: change tip when selecting using mouse; fixed #2507
  • Loading branch information
th3coop authored Jul 16, 2019
2 parents 68441f0 + 0253866 commit 0a368bf
Showing 1 changed file with 34 additions and 2 deletions.
36 changes: 34 additions & 2 deletions src/modules/commando/content/sdk/commando.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@
elem('results').on("keydown", onKeyNav.bind(this));
elem('results').on("dblclick", onSelectResult.bind(this));
elem('results').on("command", onSelectResult.bind(this));
elem('results').on('click', onMouseClick.bind(this));
elem('subscopeWrap').on("command", onCommandSubscope.bind(this));
elem('scopeFilter').on("command", onCommandFilter.bind(this));

Expand All @@ -135,7 +136,7 @@
if (e.target.nodeName == "label" && e.target.getAttribute("anonid") == "notification-widget-text")
onQuickSearchFocus();
});

if (window == _window)
{
local.transitKeyBinds = prefs.getBoolean("transit_commando_keybinds", false);
Expand Down Expand Up @@ -218,6 +219,13 @@
};

/** Controllers **/

var onMouseClick = (e) => {
c.mouseClick(e);
e.preventDefault();
e.stopPropagation();
return false;
};

var onKeyNav = function(e)
{
Expand All @@ -226,7 +234,7 @@
var results = elem('results');
if ( ! results.visible()) return;
var prevDefault = false;

if (local.blocked)
{
e.preventDefault();
Expand Down Expand Up @@ -1714,6 +1722,30 @@
c.tip(description);
}
}

this.mouseClick = (e) => {
let results = elem('results'),
resultElem = results.element(),
selectedItems = resultElem.selectedItems,
selectedItem = resultElem.selectedItem;

if (selectedItems.length > 1) {
let filtered = selectedItems.filter(item => item.resultData.allowMultiSelect);
let suffix = {
files: filtered.length != 1 ? 's' : '',
folders: (selectedItems.length - filtered.length) != 1 ? 's' : ''
};
c.tip(`Selected ${filtered.length} file${suffix.files}; ignoring ${selectedItems.length - filtered.length} folder${suffix.folders}`);
} else if (selectedItem) {
let data = selectedItem.resultData;
let description = data.name;
if ("tip" in data) description = data.tip;
if (("description" in data) && data.description && data.description.length)
description = data.name + " - " + data.description;
c.tip(description);
}

}

this.navUp = function(append = false)
{
Expand Down

0 comments on commit 0a368bf

Please sign in to comment.