Add: openManage API
This commit is contained in:
parent
4ae74171cb
commit
f86a678a1f
|
@ -73,7 +73,9 @@ window.API_METHODS = Object.assign(window.API_METHODS || {}, {
|
|||
syncStop: sync.stop,
|
||||
syncNow: sync.syncNow,
|
||||
getSyncStatus: sync.getStatus,
|
||||
syncLogin: sync.login
|
||||
syncLogin: sync.login,
|
||||
|
||||
openManage
|
||||
});
|
||||
|
||||
// eslint-disable-next-line no-var
|
||||
|
@ -178,12 +180,8 @@ chrome.runtime.onInstalled.addListener(({reason}) => {
|
|||
// *************************************************************************
|
||||
// browser commands
|
||||
browserCommands = {
|
||||
openManage() {
|
||||
openURL({url: 'manage.html', currentWindow: null});
|
||||
},
|
||||
openOptions() {
|
||||
openURL({url: 'manage.html#stylus-options', currentWindow: null});
|
||||
},
|
||||
openManage,
|
||||
openOptions: () => openManage({options: true}),
|
||||
styleDisableAll(info) {
|
||||
prefs.set('disableAll', info ? info.checked : !prefs.get('disableAll'));
|
||||
},
|
||||
|
@ -413,3 +411,14 @@ function openEditor(params) {
|
|||
openURL({url});
|
||||
}
|
||||
}
|
||||
|
||||
function openManage({options = false, search} = {}) {
|
||||
let url = 'manage.html';
|
||||
if (search) {
|
||||
url += `?search=${encodeURIComponent(search)}`;
|
||||
}
|
||||
if (options) {
|
||||
url += '#stylus-options';
|
||||
}
|
||||
return openURL({url, currentWindow: null});
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ document.onclick = e => {
|
|||
|
||||
switch (target.dataset.cmd) {
|
||||
case 'open-manage':
|
||||
openURL({url: 'manage.html'});
|
||||
API.openManage();
|
||||
break;
|
||||
|
||||
case 'check-updates':
|
||||
|
|
|
@ -102,7 +102,7 @@ function initPopup() {
|
|||
});
|
||||
|
||||
$('#popup-options-button').onclick = () => {
|
||||
API.openURL({url: 'manage.html#stylus-options', currentWindow: null});
|
||||
API.openManage({options: true});
|
||||
window.close();
|
||||
};
|
||||
|
||||
|
@ -591,9 +591,10 @@ Object.assign(handleEvent, {
|
|||
if (!this.eventHandled) {
|
||||
// FIXME: this only works if popup is closed
|
||||
this.eventHandled = true;
|
||||
this.dataset.href += event.shiftKey || event.button === 2 ?
|
||||
'?search=' + encodeURIComponent(`url:${tabURL}`) : '';
|
||||
API.openURL({url: this.dataset.href, currentWindow: null});
|
||||
API.openManage({
|
||||
search: event.shiftKey || event.button === 2 ?
|
||||
`url:${tabURL}` : null
|
||||
});
|
||||
window.close();
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue
Block a user