Display new options in popup, update ExecAction
This commit is contained in:
parent
d0058cedb9
commit
cda5d87735
@ -12,6 +12,9 @@ export default {
|
||||
aspectRatioActions: function(){
|
||||
return this.scopeActions.filter(x => x.cmd.length === 1 && x.cmd[0].action === 'set-ar') || [];
|
||||
},
|
||||
cropModePersistenceActions: function() {
|
||||
return this.scopeActions.filter(x => x.cmd.length === 1 && x.cmd[0].action === 'set-ar-persistence') || [];
|
||||
},
|
||||
stretchActions: function(){
|
||||
return this.scopeActions.filter(x => x.cmd.length === 1 && x.cmd[0].action === 'set-stretch') || [];
|
||||
},
|
||||
|
@ -574,6 +574,22 @@ class PageInfo {
|
||||
this.actionHandler.setKeybordLocal(state);
|
||||
}
|
||||
|
||||
setArPersistence(persistenceMode) {
|
||||
if (persistenceMode === CropModePersistence.CurrentSession) {
|
||||
sessionStorage.setItem('uw-crop-mode-session-persistence', JSON.stringify(this.currentCrop));
|
||||
} else if (persistenceMode === CropModePersistence.Forever) {
|
||||
if (this.settings.active.sites[window.location.host]) {
|
||||
// | key may be missing, so we do this
|
||||
this.settings.active.sites[window.location.host]['defaultAr'] = this.currentCrop;
|
||||
} else {
|
||||
this.settings.active.sites[window.location.host] = this.settings.getDefaultOption();
|
||||
this.settings.active.sites[window.location.host]['defaultAr'] = this.currentCrop;
|
||||
}
|
||||
|
||||
this.settings.saveWithoutReload();
|
||||
}
|
||||
}
|
||||
|
||||
setDefaultCrop(ar) {
|
||||
this.currentCrop = ar;
|
||||
// This means crop persistance is disabled. If crop persistance is enabled, then settings for current
|
||||
@ -594,10 +610,8 @@ class PageInfo {
|
||||
// | key may be missing, so we do this
|
||||
this.settings.active.sites[window.location.host]['defaultAr'] = ar;
|
||||
} else {
|
||||
// add options for new site if they're missing!
|
||||
this.settings.active.sites[window.location.host] = {
|
||||
defaultAr: ar,
|
||||
}
|
||||
this.settings.active.sites[window.location.host] = this.settings.getDefaultOption();
|
||||
this.settings.active.sites[window.location.host]['defaultAr'] = ar;
|
||||
}
|
||||
|
||||
this.settings.saveWithoutReload();
|
||||
|
@ -13,7 +13,7 @@ class ExecAction {
|
||||
this.site = site;
|
||||
}
|
||||
|
||||
exec(action, scope, frame) {
|
||||
async exec(action, scope, frame) {
|
||||
for (var cmd of action.cmd) {
|
||||
if (scope === 'page') {
|
||||
const message = {
|
||||
@ -27,6 +27,32 @@ class ExecAction {
|
||||
Comms.sendMessage(message);
|
||||
} else {
|
||||
|
||||
// set-ar-persistence sends stuff to content scripts as well (!)
|
||||
// it's important to do that BEFORE the save step
|
||||
if (cmd === 'set-ar-persistence') {
|
||||
let message;
|
||||
if (scope === 'site') {
|
||||
message = {
|
||||
forwardToContentScript: true,
|
||||
targetFrame: frame,
|
||||
frame: frame,
|
||||
cmd: cmd.action,
|
||||
arg: cmd.arg,
|
||||
}
|
||||
} else {
|
||||
message = {
|
||||
forwardToAll: true,
|
||||
targetFrame: frame,
|
||||
frame: frame,
|
||||
cmd: cmd.action,
|
||||
arg: cmd.arg,
|
||||
}
|
||||
}
|
||||
// this hopefully delays settings.save() until current crops are saved on the site
|
||||
// and thus avoid any fucky-wuckies
|
||||
await Comms.sendMessage(message);
|
||||
}
|
||||
|
||||
let site = this.site;
|
||||
if (scope === 'global') {
|
||||
site = '@global';
|
||||
|
@ -31,7 +31,7 @@
|
||||
<div class="flex flex-row flex-wrap">
|
||||
<ShortcutButton v-for="(action, index) of aardActions"
|
||||
class="flex flex-grow button"
|
||||
:class="{'setting-selected': getCurrent('autoar') === action.cmd[0].arg}"
|
||||
:class="{'setting-selected': getCurrent('cropModePersistence') === action.cmd[0].arg}"
|
||||
:key="index"
|
||||
:label="(action.scopes[scope] && action.scopes[scope].label) ? action.scopes[scope].label : action.label"
|
||||
:shortcut="parseShortcut(action)"
|
||||
@ -42,9 +42,27 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- CROP MODE PERSISTENCE -->
|
||||
<div v-if="cropModePersistenceActions.length"
|
||||
class="w100"
|
||||
>
|
||||
<div class="label">Persists crop mode <template v-if="scope === 'site'">for {{site}}</template>:</div>
|
||||
<div class="flex flex-row flex-wrap">
|
||||
<ShortcutButton v-for="(action, index) of cropModePersistenceActions"
|
||||
class="flex flex-grow button"
|
||||
:class="{'setting-selected': getCurrent('autoar') === action.cmd[0].arg}"
|
||||
:key="index"
|
||||
:label="(action.scopes[scope] && action.scopes[scope].label) ? action.scopes[scope].label : action.label"
|
||||
:shortcut="parseShortcut(action)"
|
||||
@click.native="execAction(action)"
|
||||
>
|
||||
</ShortcutButton>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- DEFAULT SETTINGS -->
|
||||
<div v-if="stretchActions.length">
|
||||
<div class="label">Default stretching mode:</div>
|
||||
<div class="label experimental">Default stretching mode:</div>
|
||||
<div class="flex flex-row flex-wrap">
|
||||
<ShortcutButton v-for="(action, index) of stretchActions"
|
||||
class="flex b3 flex-grow button"
|
||||
|
@ -5,6 +5,13 @@
|
||||
</div>
|
||||
<div v-if="aspectRatioActions.length">
|
||||
<div class="label">Cropping mode:</div>
|
||||
<div v-if="cropModePersistence && cropModePersistence > CropModePersistence.Disabled" class="info">
|
||||
Cropping mode will persist
|
||||
<template v-if="cropModePersistence === CropModePersistence.UntilPageReload">until page reload (this includes page navigation!).</template>
|
||||
<template v-if="cropModePersistence === CropModePersistence.CurrentSession">for current session.</template>
|
||||
<template v-if="cropModePersistence === CropModePersistence.Forever">forever (or at least until you change aspect ratio manually).</template>
|
||||
This can be changed in the 'site settings' or 'extension settings' tab.
|
||||
</div>
|
||||
<div class="flex flex-row flex-wrap">
|
||||
<ShortcutButton v-for="(action, index) of aspectRatioActions"
|
||||
class="flex b3 flex-grow button"
|
||||
@ -12,7 +19,7 @@
|
||||
:label="(action.scopes.page && action.scopes.page.label) ? action.scopes.page.label : action.label"
|
||||
:shortcut="parseShortcut(action)"
|
||||
@click.native="execAction(action)"
|
||||
>
|
||||
>
|
||||
</ShortcutButton>
|
||||
</div>
|
||||
</div>
|
||||
@ -117,11 +124,13 @@ import ExecAction from '../js/ExecAction';
|
||||
import KeyboardShortcutParser from '../../common/js/KeyboardShortcutParser';
|
||||
import ShortcutButton from '../../common/components/ShortcutButton';
|
||||
import ComputeActionsMixin from '../../common/mixins/ComputeActionsMixin';
|
||||
import CropModePersistence from '../../common/enums/crop-mode-persistence.enum';
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
scope: 'page',
|
||||
CropModePersistence: CropModePersistence,
|
||||
}
|
||||
},
|
||||
mixins: [
|
||||
@ -131,7 +140,8 @@ export default {
|
||||
'settings',
|
||||
'frame',
|
||||
'zoom',
|
||||
'someSitesDisabledWarning'
|
||||
'someSitesDisabledWarning',
|
||||
'cropModePersistence',
|
||||
],
|
||||
created() {
|
||||
this.exec = new ExecAction(this.settings);
|
||||
|
Loading…
Reference in New Issue
Block a user