Merge pull request #400 from bakulf/foo
Fix the opening of a link from a context menu - issue #327
This commit is contained in:
commit
7de6ef5306
1 changed files with 41 additions and 18 deletions
59
index.js
59
index.js
|
@ -1370,25 +1370,48 @@ ContainerWindow.prototype = {
|
||||||
},
|
},
|
||||||
|
|
||||||
_configureContextMenu() {
|
_configureContextMenu() {
|
||||||
return this._configureMenu("context-openlinkinusercontext-menu",
|
return Promise.all([
|
||||||
() => {
|
this._configureMenu("context-openlinkinusercontext-menu",
|
||||||
// This userContextId is what we want to exclude.
|
() => {
|
||||||
const tab = modelFor(this._window).tabs.activeTab;
|
// This userContextId is what we want to exclude.
|
||||||
return ContainerService._getUserContextIdFromTab(tab);
|
const tab = modelFor(this._window).tabs.activeTab;
|
||||||
},
|
return ContainerService._getUserContextIdFromTab(tab);
|
||||||
e => {
|
},
|
||||||
// This is a super internal method. Hopefully it will be stable in the
|
e => {
|
||||||
// next FF releases.
|
// This is a super internal method. Hopefully it will be stable in the
|
||||||
this._window.gContextMenu.openLinkInTab(e);
|
// next FF releases.
|
||||||
|
this._window.gContextMenu.openLinkInTab(e);
|
||||||
|
|
||||||
const userContextId = parseInt(e.target.getAttribute("data-usercontextid"), 10);
|
const userContextId = parseInt(e.target.getAttribute("data-usercontextid"), 10);
|
||||||
ContainerService.showTabs({
|
ContainerService.showTabs({
|
||||||
userContextId,
|
userContextId,
|
||||||
nofocus: true,
|
nofocus: true,
|
||||||
window: this._window,
|
window: this._window,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
),
|
||||||
|
this._configureContextMenuOpenLink(),
|
||||||
|
]);
|
||||||
|
},
|
||||||
|
|
||||||
|
_configureContextMenuOpenLink() {
|
||||||
|
return new Promise(resolve => {
|
||||||
|
const self = this;
|
||||||
|
this._window.gSetUserContextIdAndClick = function(event) {
|
||||||
|
const tab = modelFor(self._window).tabs.activeTab;
|
||||||
|
const userContextId = ContainerService._getUserContextIdFromTab(tab);
|
||||||
|
event.target.setAttribute("data-usercontextid", userContextId);
|
||||||
|
self._window.gContextMenu.openLinkInTab(event);
|
||||||
|
};
|
||||||
|
|
||||||
|
let item = this._window.document.getElementById("context-openlinkincontainertab");
|
||||||
|
item.setAttribute("oncommand", "gSetUserContextIdAndClick(event)");
|
||||||
|
|
||||||
|
item = this._window.document.getElementById("context-openlinkintab");
|
||||||
|
item.setAttribute("oncommand", "gSetUserContextIdAndClick(event)");
|
||||||
|
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
// Generic menu configuration.
|
// Generic menu configuration.
|
||||||
|
|
Loading…
Add table
Reference in a new issue