2018-04-28 17:56:03 -04:00
< template lang = "html" >
2018-09-25 18:37:14 -04:00
< div class = "ffz--action tw-elevation-1 tw-c-background-base tw-border tw-pd-y-05 tw-pd-r-1 tw-mg-y-05 tw-flex tw-flex-nowrap" >
2018-04-28 17:56:03 -04:00
< div class = "tw-flex tw-flex-shrink-0 tw-align-items-start handle tw-pd-x-05 tw-pd-t-1 tw-pd-b-05" >
< span class = "ffz-i-ellipsis-vert" / >
< / div >
< div class = "tw-flex-grow-1" >
< template v-if = "! editing" >
< h4 > { { title } } < / h4 >
2019-06-20 15:15:54 -04:00
< div class = "description" >
{ { description } }
< / div >
2018-04-28 17:56:03 -04:00
< div v-if = "canEdit" class="visibility tw-c-text-alt" >
2019-05-03 19:30:46 -04:00
{ { t ( 'setting.actions.visible' , 'visible: {list}' , { list : visibility } ) } }
2018-04-28 17:56:03 -04:00
< / div >
< / template >
2020-05-27 15:44:37 -04:00
< template v -else -if = " copying " >
< textarea
ref = "json"
v - model = "json"
readonly
2021-02-11 19:40:12 -05:00
class = "tw-full-width tw-full-height tw-border-radius-medium tw-font-size-6 tw-pd-x-1 tw-pd-y-05 ffz-input"
2020-05-27 15:44:37 -04:00
@ focus = "$event.target.select()"
/ >
< / template >
2018-04-28 17:56:03 -04:00
< template v-else >
< section >
< h5 > { { t ( 'setting.actions.appearance' , 'Appearance' ) } } < / h5 >
< div class = "tw-flex tw-align-items-center" >
< label for = "tooltip" >
{ { t ( 'setting.actions.tooltip' , 'Custom Tooltip' ) } }
< / label >
< input
v - model = "edit_data.appearance.tooltip"
2021-02-11 19:40:12 -05:00
class = "tw-border-radius-medium tw-font-size-6 tw-full-width ffz-input tw-pd-x-1 tw-pd-y-05 tw-mg-y-05"
2018-04-28 17:56:03 -04:00
>
< / div >
< div class = "tw-flex tw-align-items-center" >
< label for = "renderer_type" >
{ { t ( 'setting.actions.type' , 'Type' ) } }
< / label >
< select
id = "renderer_type"
ref = "renderer_type"
v - model = "edit_data.appearance.type"
2021-02-11 19:40:12 -05:00
class = "tw-border-radius-medium tw-font-size-6 tw-full-width ffz-select tw-pd-l-1 tw-pd-r-3 tw-pd-y-05 tw-mg-y-05"
2018-04-28 17:56:03 -04:00
>
< option
v - for = "(r, key) in data.renderers"
2022-12-07 16:52:07 -05:00
v - if = "supportsRenderer(key)"
2018-04-28 17:56:03 -04:00
: key = "key"
: value = "key"
>
{ { r . title _i18n ? t ( r . title _i18n , r . title , r ) : r . title } }
< / option >
< / select >
< / div >
< div v-if = "renderer && renderer.colored" class="tw-flex tw-align-items-start" >
< label for = "color" class = "tw-mg-y-05" >
{ { t ( 'setting.actions.color' , 'Color' ) } }
< / label >
< div class = "tw-full-width" >
< color-picker v-model = "edit_data.appearance.color" :nullable="true" / >
< div class = "tw-c-text-alt-2 tw-mg-b-1" >
{ { t ( 'setting.actions.color.warn' , 'This value will be automatically adjusted for visibility based on your chat color settings.' ) } }
< / div >
< / div >
< / div >
< component
: is = "renderer.editor"
2019-06-20 15:15:54 -04:00
v - if = "renderer"
2018-04-28 17:56:03 -04:00
v - model = "edit_data.appearance"
/ >
< / section >
< section class = "tw-mg-t-1 tw-border-t tw-pd-t-1" >
< h5 > { { t ( 'setting.actions.visibility' , 'Visibility' ) } } < / h5 >
< div class = "tw-flex tw-align-items-center" >
< label for = "vis_mod" >
{ { t ( 'setting.actions.edit-visible.mod' , 'Moderator' ) } }
< / label >
< select
id = "vis_mod"
v - model = "edit_data.display.mod"
2021-02-11 19:40:12 -05:00
class = "tw-border-radius-medium tw-font-size-6 tw-full-width ffz-select tw-pd-l-1 tw-pd-r-3 tw-pd-y-05 tw-mg-y-05"
2018-04-28 17:56:03 -04:00
>
2019-06-20 15:15:54 -04:00
< option :value = "undefined" selected >
{ { t ( 'setting.unset' , 'Unset' ) } }
< / option >
< option :value = "true" >
{ { t ( 'setting.true' , 'True' ) } }
< / option >
< option :value = "false" >
{ { t ( 'setting.false' , 'False' ) } }
< / option >
2018-04-28 17:56:03 -04:00
< / select >
< / div >
2019-08-06 15:39:45 -04:00
< div v-if = "mod_icons" class="tw-flex tw-align-items-center" >
2018-04-28 17:56:03 -04:00
< label for = "vis_mod_icons" >
{ { t ( 'setting.actions.edit-visible.mod-icons' , 'Mod Icons' ) } }
< / label >
< select
id = "vis_mod_icons"
v - model = "edit_data.display.mod_icons"
2021-02-11 19:40:12 -05:00
class = "tw-border-radius-medium tw-font-size-6 tw-full-width ffz-select tw-pd-l-1 tw-pd-r-3 tw-pd-y-05 tw-mg-y-05"
2018-04-28 17:56:03 -04:00
>
2019-06-20 15:15:54 -04:00
< option :value = "undefined" selected >
{ { t ( 'setting.unset' , 'Unset' ) } }
< / option >
< option :value = "true" >
{ { t ( 'setting.visible' , 'Visible' ) } }
< / option >
< option :value = "false" >
{ { t ( 'setting.hidden' , 'Hidden' ) } }
< / option >
2018-04-28 17:56:03 -04:00
< / select >
< / div >
2019-05-07 15:04:12 -04:00
< div v-if = "has_message" class="tw-flex tw-align-items-center" >
2018-04-28 17:56:03 -04:00
< label for = "vis_deleted" >
{ { t ( 'setting.actions.edit-visible.deleted' , 'Message Deleted' ) } }
< / label >
< select
id = "vis_deleted"
v - model = "edit_data.display.deleted"
2021-02-11 19:40:12 -05:00
class = "tw-border-radius-medium tw-font-size-6 tw-full-width ffz-select tw-pd-l-1 tw-pd-r-3 tw-pd-y-05 tw-mg-y-05"
2018-04-28 17:56:03 -04:00
>
2019-06-20 15:15:54 -04:00
< option :value = "undefined" selected >
{ { t ( 'setting.unset' , 'Unset' ) } }
< / option >
< option :value = "true" >
{ { t ( 'setting.true' , 'True' ) } }
< / option >
< option :value = "false" >
{ { t ( 'setting.false' , 'False' ) } }
< / option >
2018-04-28 17:56:03 -04:00
< / select >
< / div >
2019-05-16 14:46:26 -04:00
2019-08-12 22:52:57 -04:00
< div v-if = "has_mode" class="tw-flex tw-align-items-center" >
< label for = "vis_emote" >
{ { t ( 'setting.actions.edit-visible.emote-only' , 'Emote-Only Mode' ) } }
< / label >
< select
id = "vis_emote"
v - model = "edit_data.display.emoteOnly"
2021-02-11 19:40:12 -05:00
class = "tw-border-radius-medium tw-font-size-6 tw-full-width ffz-select tw-pd-l-1 tw-pd-r-3 tw-pd-y-05 tw-mg-y-05"
2019-08-12 22:52:57 -04:00
>
< option :value = "undefined" selected >
{ { t ( 'setting.unset' , 'Unset' ) } }
< / option >
< option :value = "true" >
{ { t ( 'setting.true' , 'True' ) } }
< / option >
< option :value = "false" >
{ { t ( 'setting.false' , 'False' ) } }
< / option >
< / select >
< / div >
< div v-if = "has_mode" class="tw-flex tw-align-items-center" >
< label for = "vis_slow" >
{ { t ( 'setting.actions.edit-visible.slow' , 'Slow Mode' ) } }
< / label >
< select
id = "vis_slow"
v - model = "edit_data.display.slowMode"
2021-02-11 19:40:12 -05:00
class = "tw-border-radius-medium tw-font-size-6 tw-full-width ffz-select tw-pd-l-1 tw-pd-r-3 tw-pd-y-05 tw-mg-y-05"
2019-08-12 22:52:57 -04:00
>
< option :value = "undefined" selected >
{ { t ( 'setting.unset' , 'Unset' ) } }
< / option >
< option :value = "true" >
{ { t ( 'setting.true' , 'True' ) } }
< / option >
< option :value = "false" >
{ { t ( 'setting.false' , 'False' ) } }
< / option >
< / select >
< / div >
2019-08-27 16:18:12 -04:00
< div v-if = "has_mode" class="tw-flex tw-align-items-center" >
< label for = "vis_follows" >
{ { t ( 'setting.actions.edit-visible.follows' , 'Follower-Only Mode' ) } }
< / label >
< select
id = "vis_subs"
v - model = "edit_data.display.followersOnly"
2021-02-11 19:40:12 -05:00
class = "tw-border-radius-medium tw-font-size-6 tw-full-width ffz-select tw-pd-l-1 tw-pd-r-3 tw-pd-y-05 tw-mg-y-05"
2019-08-27 16:18:12 -04:00
>
< option :value = "undefined" selected >
{ { t ( 'setting.unset' , 'Unset' ) } }
< / option >
< option :value = "true" >
{ { t ( 'setting.true' , 'True' ) } }
< / option >
< option :value = "false" >
{ { t ( 'setting.false' , 'False' ) } }
< / option >
< / select >
< / div >
2019-08-12 22:52:57 -04:00
< div v-if = "has_mode" class="tw-flex tw-align-items-center" >
< label for = "vis_subs" >
{ { t ( 'setting.actions.edit-visible.subs' , 'Subs Mode' ) } }
< / label >
< select
id = "vis_subs"
v - model = "edit_data.display.subsMode"
2021-02-11 19:40:12 -05:00
class = "tw-border-radius-medium tw-font-size-6 tw-full-width ffz-select tw-pd-l-1 tw-pd-r-3 tw-pd-y-05 tw-mg-y-05"
2019-08-12 22:52:57 -04:00
>
< option :value = "undefined" selected >
{ { t ( 'setting.unset' , 'Unset' ) } }
< / option >
< option :value = "true" >
{ { t ( 'setting.true' , 'True' ) } }
< / option >
< option :value = "false" >
{ { t ( 'setting.false' , 'False' ) } }
< / option >
< / select >
< / div >
2019-08-27 16:18:12 -04:00
< div v-if = "has_mode" class="tw-flex tw-align-items-center" >
< label for = "vis_r9k" >
{ { t ( 'setting.actions.edit-visible.r9k' , 'R9k Mode' ) } }
< / label >
< select
id = "vis_r9k"
v - model = "edit_data.display.r9kMode"
2021-02-11 19:40:12 -05:00
class = "tw-border-radius-medium tw-font-size-6 tw-full-width ffz-select tw-pd-l-1 tw-pd-r-3 tw-pd-y-05 tw-mg-y-05"
2019-08-27 16:18:12 -04:00
>
< option :value = "undefined" selected >
{ { t ( 'setting.unset' , 'Unset' ) } }
< / option >
< option :value = "true" >
{ { t ( 'setting.true' , 'True' ) } }
< / option >
< option :value = "false" >
{ { t ( 'setting.false' , 'False' ) } }
< / option >
< / select >
< / div >
2019-05-16 14:46:26 -04:00
< div v-if = "has_modifiers" class="tw-flex tw-align-items-start" >
< label for = "vis_modifiers" >
{ { t ( 'setting.actions.edit-visible.modifier' , 'Modifiers' ) } }
< / label >
< div >
< div class = "ffz--inline tw-flex" >
2021-02-11 19:40:12 -05:00
< div class = "tw-pd-r-1 ffz-checkbox" >
2019-05-16 14:46:26 -04:00
< input
2019-05-16 20:24:34 -04:00
: id = "'key_ctrl$' + id"
2019-06-20 15:15:54 -04:00
ref = "key_ctrl"
2019-05-16 14:46:26 -04:00
: checked = "edit_data.display.keys & 1"
type = "checkbox"
2021-02-11 19:40:12 -05:00
class = "ffz-checkbox__input"
2019-05-16 14:46:26 -04:00
@ change = "onChangeKeys"
>
2021-02-11 19:40:12 -05:00
< label : for = "'key_ctrl$' + id" class = "ffz-checkbox__label" >
2020-02-09 15:10:12 -05:00
< span class = "tw-mg-l-1" >
{ { t ( 'setting.key.ctrl' , 'Ctrl' ) } }
< / span >
2019-05-16 14:46:26 -04:00
< / label >
< / div >
2021-02-11 19:40:12 -05:00
< div class = "tw-pd-r-1 ffz-checkbox" >
2019-05-16 14:46:26 -04:00
< input
2019-05-16 20:24:34 -04:00
: id = "'key_shift$' + id"
2019-06-20 15:15:54 -04:00
ref = "key_shift"
2019-05-16 14:46:26 -04:00
: checked = "edit_data.display.keys & 2"
type = "checkbox"
2021-02-11 19:40:12 -05:00
class = "ffz-checkbox__input"
2019-05-16 14:46:26 -04:00
@ change = "onChangeKeys"
>
2021-02-11 19:40:12 -05:00
< label : for = "'key_shift$' + id" class = "ffz-checkbox__label" >
2020-02-09 15:10:12 -05:00
< span class = "tw-mg-l-1" >
{ { t ( 'setting.key.shift' , 'Shift' ) } }
< / span >
2019-05-16 14:46:26 -04:00
< / label >
< / div >
2021-02-11 19:40:12 -05:00
< div class = "tw-pd-r-1 ffz-checkbox" >
2019-05-16 14:46:26 -04:00
< input
2019-05-16 20:24:34 -04:00
: id = "'key_alt$' + id"
2019-06-20 15:15:54 -04:00
ref = "key_alt"
2019-05-16 14:46:26 -04:00
: checked = "edit_data.display.keys & 4"
type = "checkbox"
2021-02-11 19:40:12 -05:00
class = "ffz-checkbox__input"
2019-05-16 14:46:26 -04:00
@ change = "onChangeKeys"
>
2021-02-11 19:40:12 -05:00
< label : for = "'key_alt$' + id" class = "ffz-checkbox__label" >
2020-02-09 15:10:12 -05:00
< span class = "tw-mg-l-1" >
{ { t ( 'setting.key.alt' , 'Alt' ) } }
< / span >
2019-05-16 14:46:26 -04:00
< / label >
< / div >
2021-02-11 19:40:12 -05:00
< div class = "tw-pd-r-1 ffz-checkbox" >
2019-05-16 14:46:26 -04:00
< input
2019-05-16 20:24:34 -04:00
: id = "'key_meta$' + id"
2019-06-20 15:15:54 -04:00
ref = "key_meta"
2019-05-16 14:46:26 -04:00
: checked = "edit_data.display.keys & 8"
type = "checkbox"
2021-02-11 19:40:12 -05:00
class = "ffz-checkbox__input"
2019-05-16 14:46:26 -04:00
@ change = "onChangeKeys"
>
2021-02-11 19:40:12 -05:00
< label : for = "'key_meta$' + id" class = "ffz-checkbox__label" >
2020-02-09 15:10:12 -05:00
< span class = "tw-mg-l-1" >
{ { t ( 'setting.key.meta' , 'Meta' ) } }
< / span >
2019-05-16 14:46:26 -04:00
< / label >
< / div >
2020-08-13 14:00:47 -04:00
2022-12-07 16:52:07 -05:00
< div v-if = "has_hover_modifier" class="tw-pd-r-1 ffz-checkbox" >
2020-08-13 14:00:47 -04:00
< input
: id = "'key_hover$' + id"
ref = "key_hover"
: checked = "edit_data.display.hover"
type = "checkbox"
2021-02-11 19:40:12 -05:00
class = "ffz-checkbox__input"
2020-08-13 14:00:47 -04:00
@ change = "onChangeKeys"
>
2021-02-11 19:40:12 -05:00
< label : for = "'key_hover$' + id" class = "ffz-checkbox__label" >
2020-08-13 14:00:47 -04:00
< span class = "tw-mg-l-1" >
{ { t ( 'setting.key.hover' , 'Hover' ) } }
< / span >
< / label >
< / div >
2019-05-16 14:46:26 -04:00
< / div >
< / div >
< / div >
2018-04-28 17:56:03 -04:00
< / section >
< section class = "tw-mg-t-1 tw-border-t tw-pd-t-1" >
< h5 > { { t ( 'setting.actions.action' , 'Action' ) } } < / h5 >
< div class = "tw-flex tw-align-items-center" >
< label for = "action_type" >
{ { t ( 'setting.actions.type' , 'Type' ) } }
< / label >
< select
id = "action_type"
v - model = "edit_data.action"
2021-02-11 19:40:12 -05:00
class = "tw-border-radius-medium tw-font-size-6 tw-full-width ffz-select tw-pd-l-1 tw-pd-r-3 tw-pd-y-05 tw-mg-y-05"
2018-04-28 17:56:03 -04:00
>
< option
v - for = "(a, key) in data.actions"
: key = "key"
: value = "key"
>
2020-03-06 01:44:33 -05:00
{ { t ( a . title _i18n || ` chat.actions. ${ key } ` , a . title , a ) } }
2018-04-28 17:56:03 -04:00
< / option >
< / select >
< / div >
< component
: is = "action_def.editor"
2019-06-20 15:15:54 -04:00
v - if = "action_def && action_def.editor"
2018-04-28 17:56:03 -04:00
: value = "edit_data.options"
: defaults = "action_def.defaults"
: vars = "vars"
2022-04-19 15:34:20 -04:00
: fmts = "fmts"
2018-04-28 17:56:03 -04:00
@ input = "onChangeAction($event)"
/ >
< / section >
< / template >
< / div >
< div v-if = "canPreview" class="tw-mg-l-1 tw-border-l tw-pd-l-1 tw-pd-y-05 tw-flex tw-flex-shrink-0 tw-align-items-start" >
< action-preview
2022-12-07 16:52:07 -05:00
: act = "maybeDynamic(display)"
: process - color = "data.color"
2018-04-28 17:56:03 -04:00
: renderers = "data.renderers"
/ >
< / div >
< div class = "tw-mg-l-1 tw-border-l tw-pd-l-1 tw-flex tw-flex-wrap tw-flex-column tw-justify-content-start tw-align-items-start" >
2020-05-27 15:44:37 -04:00
< template v-if = "copying" >
< button class = "tw-button tw-button--text" @ click = "copying = false" >
< span class = "tw-button__text ffz-i-cancel" >
{ { t ( 'setting.cancel' , 'Cancel' ) } }
< / span >
< / button >
< / template >
< template v-if = "editing && ! copying" >
2018-04-28 17:56:03 -04:00
< button class = "tw-button tw-button--text" @click ="save" >
< span class = "tw-button__text ffz-i-floppy" >
{ { t ( 'setting.save' , 'Save' ) } }
< / span >
< / button >
< button class = "tw-button tw-button--text" @click ="cancel" >
< span class = "tw-button__text ffz-i-cancel" >
{ { t ( 'setting.cancel' , 'Cancel' ) } }
< / span >
< / button >
2020-05-27 15:44:37 -04:00
< button class = "tw-button tw-button--text" @click ="prepareCopy" >
< span class = "tw-button__text ffz-i-docs" >
{ { t ( 'setting.copy-json' , 'Copy' ) } }
< / span >
< / button >
2018-04-28 17:56:03 -04:00
< / template >
2020-05-27 15:44:37 -04:00
< template v -else -if = " deleting & & ! copying " >
2018-05-10 19:56:39 -04:00
< button class = "tw-button tw-button--text" @ click = "$emit('remove', action)" >
< span class = "tw-button__text ffz-i-trash" >
{ { t ( 'setting.delete' , 'Delete' ) } }
< / span >
< / button >
< button class = "tw-button tw-button--text" @ click = "deleting = false" >
< span class = "tw-button__text ffz-i-cancel" >
{ { t ( 'setting.cancel' , 'Cancel' ) } }
< / span >
< / button >
< / template >
2020-05-27 15:44:37 -04:00
< template v -else -if = " ! copying " >
2018-04-28 17:56:03 -04:00
< button
v - if = "canEdit"
class = "tw-button tw-button--text"
@ click = "edit"
>
< span class = "tw-button__text ffz-i-cog" >
{ { t ( 'setting.edit' , 'Edit' ) } }
< / span >
< / button >
2018-05-10 19:56:39 -04:00
< button class = "tw-button tw-button--text" @ click = "deleting = true" >
2018-04-28 17:56:03 -04:00
< span class = "tw-button__text ffz-i-trash" >
{ { t ( 'setting.delete' , 'Delete' ) } }
< / span >
< / button >
< / template >
< / div >
< / div >
< / template >
< script >
import { has , maybe _call , deep _copy } from 'utilities/object' ;
2019-05-16 20:24:34 -04:00
let id = 0 ;
2018-04-28 17:56:03 -04:00
export default {
2022-12-07 16:52:07 -05:00
props : [ 'vuectx' , 'action' , 'data' , 'inline' , 'mod_icons' , 'context' , 'modifiers' , 'hover_modifier' ] ,
2018-04-28 17:56:03 -04:00
data ( ) {
return {
2019-05-16 20:24:34 -04:00
id : id ++ ,
2020-05-27 15:44:37 -04:00
copying : false ,
2018-05-10 19:56:39 -04:00
deleting : false ,
2018-04-28 17:56:03 -04:00
editing : false ,
edit _data : null
}
} ,
computed : {
2020-05-27 15:44:37 -04:00
json ( ) {
return JSON . stringify ( this . display )
} ,
2018-04-28 17:56:03 -04:00
display ( ) {
if ( this . editing )
return this . edit _data ;
return this . action . v ;
} ,
2019-05-07 15:04:12 -04:00
has _message ( ) {
return this . context && this . context . includes ( 'message' )
} ,
2018-04-28 17:56:03 -04:00
2019-08-12 22:52:57 -04:00
has _mode ( ) {
return this . context && this . context . includes ( 'room-mode' )
} ,
2019-05-16 14:46:26 -04:00
has _modifiers ( ) {
return this . modifiers
} ,
2022-12-07 16:52:07 -05:00
has _hover _modifier ( ) {
return this . hover _modifier !== false
} ,
2022-04-19 15:34:20 -04:00
fmts ( ) {
const out = [ ] ;
out . push ( 'word(start)' ) ;
out . push ( 'word(start,end)' ) ;
out . push ( 'upper' ) ;
out . push ( 'lower' ) ;
out . push ( 'snakecase' ) ;
out . push ( 'slugify' ) ;
out . push ( 'slugify(separator)' ) ;
return out . join ( ', ' ) ;
} ,
2019-05-07 15:04:12 -04:00
vars ( ) {
const out = [ ] ,
ctx = this . context || [ ] ;
if ( ctx . includes ( 'user' ) ) {
out . push ( 'user.login' ) ;
out . push ( 'user.displayName' ) ;
out . push ( 'user.id' ) ;
out . push ( 'user.type' ) ;
}
if ( ctx . includes ( 'room' ) ) {
out . push ( 'room.login' ) ;
out . push ( 'room.id' ) ;
}
if ( ctx . includes ( 'message' ) ) {
out . push ( 'message.id' ) ;
out . push ( 'message.text' ) ;
}
2018-04-28 17:56:03 -04:00
return out . map ( x => ` {{ ${ x } }} ` ) . join ( ', ' ) ;
} ,
renderer ( ) {
return this . canPreview && this . data . renderers [ this . display . appearance . type ] ;
} ,
action _def ( ) {
return this . display && this . data . actions [ this . display . action ] ;
} ,
canEdit ( ) {
2018-07-13 14:32:12 -04:00
return this . action . v != null && ! this . action . v . type ;
2018-04-28 17:56:03 -04:00
} ,
canPreview ( ) {
return this . display && this . display . appearance ;
} ,
title ( ) {
if ( this . action . t === 'inherit' )
return this . t ( 'setting.inheritance' , 'Inheritance Point' ) ;
2022-12-08 16:19:14 -05:00
if ( this . action . t === 'skip' )
return this . t ( 'setting.inheritance.skip' , 'Not Inheriting' ) ;
2018-04-28 17:56:03 -04:00
else if ( ! this . display )
return this . t ( 'setting.unknown' , 'Unknown Value' ) ;
2018-07-13 14:32:12 -04:00
const type = this . display . type ;
if ( type === 'new-line' )
return this . t ( 'setting.new-line' , 'New Line' ) ;
else if ( type === 'space-small' )
return this . t ( 'setting.space-small' , 'Space (Small)' ) ;
else if ( type === 'space' )
return this . t ( 'setting.space' , 'Space' ) ;
2018-04-28 17:56:03 -04:00
const def = this . data . actions [ this . display . action ] ;
if ( ! def )
2019-05-03 19:30:46 -04:00
return this . t ( 'setting.actions.unknown' , 'Unknown Action Type: {action}' , this . display ) ;
2018-04-28 17:56:03 -04:00
if ( def . title ) {
const data = this . getData ( ) ,
2023-03-27 18:50:32 -04:00
out = maybe _call ( def . title , this , data , def ) ;
let i18n = maybe _call ( def . title _i18n , this , data , def ) ;
if ( i18n === undefined )
i18n = ` chat.actions. ${ this . display . action } ` ;
2018-04-28 17:56:03 -04:00
2023-03-27 18:50:32 -04:00
if ( out && i18n )
2018-04-28 17:56:03 -04:00
return this . t ( i18n , out , data ) ;
2023-03-27 18:50:32 -04:00
else if ( out )
return out ;
2018-04-28 17:56:03 -04:00
}
2019-05-03 19:30:46 -04:00
return this . t ( 'setting.actions.untitled' , 'Action: {action}' , this . display ) ;
2018-04-28 17:56:03 -04:00
} ,
description ( ) {
if ( this . action . t === 'inherit' )
2022-12-08 16:19:14 -05:00
return this . t ( 'setting.inheritance.desc' , 'Inherit values from lower priority profiles or the default values at this position.' ) ;
if ( this . action . t === 'skip' )
return this . t ( 'setting.inheritance.skip.desc' , 'This profile does not inherit values from lower priority profiles or the default values, despite having no values of its own.' ) ;
2018-04-28 17:56:03 -04:00
2018-07-13 14:32:12 -04:00
const type = this . display && this . display . type ;
if ( type === 'new-line' )
return this . t ( 'setting.new-line.desc' , 'Place all items following this on a new line.' ) ;
else if ( type === 'space-small' )
return this . t ( 'setting.space-small.desc' , 'Place a small space between the previous item and the next item.' ) ;
else if ( type === 'space' )
return this . t ( 'setting.space.desc' , 'Place as large a space as possible between the previous item and the next item.' ) ;
2018-04-28 17:56:03 -04:00
const def = this . display && this . data . actions [ this . display . action ] ;
if ( ! def || ! def . description )
2019-06-20 15:15:54 -04:00
return null ;
2018-04-28 17:56:03 -04:00
const data = this . getData ( ) ,
2023-03-27 18:50:32 -04:00
out = maybe _call ( def . description , this , data , def ) ;
let i18n = maybe _call ( def . description _i18n , this , data , def ) ;
if ( i18n === undefined )
i18n = ` chat.actions. ${ this . display . action } .desc ` ;
2018-04-28 17:56:03 -04:00
2023-03-27 18:50:32 -04:00
if ( out && i18n )
2018-04-28 17:56:03 -04:00
return this . t ( i18n , out , data ) ;
2023-03-27 18:50:32 -04:00
else if ( out )
return out ;
2019-06-20 15:15:54 -04:00
return null ;
2018-04-28 17:56:03 -04:00
} ,
visibility ( ) {
if ( ! this . display || ! this . display . appearance )
return ;
2018-05-10 19:56:39 -04:00
const disp = this . display . display || { } ,
out = [ ] ;
2018-04-28 17:56:03 -04:00
if ( disp . disable )
return this . t ( 'setting.actions.visible.never' , 'never' ) ;
if ( disp . mod === true )
out . push ( this . t ( 'setting.actions.visible.mod' , 'when moderator' ) ) ;
else if ( disp . mod === false )
out . push ( this . t ( 'setting.actions.visible.unmod' , 'when not moderator' ) ) ;
if ( disp . mod _icons === true )
out . push ( this . t ( 'setting.actions.visible.mod_icons' , 'when mod icons are shown' ) ) ;
else if ( disp . mod _icons === false )
out . push ( this . t ( 'setting.actions.visible.mod_icons_off' , 'when mod icons are hidden' ) ) ;
if ( disp . staff === true )
out . push ( this . t ( 'setting.actions.visible.staff' , 'when staff' ) ) ;
else if ( disp . staff === false )
out . push ( this . t ( 'setting.actions.visible.unstaff' , 'when not staff' ) ) ;
if ( disp . deleted === true )
out . push ( this . t ( 'setting.actions.visible.deleted' , 'if message deleted' ) ) ;
else if ( disp . deleted === false )
out . push ( this . t ( 'setting.actions.visible.undeleted' , 'if message not deleted' ) ) ;
2019-08-12 22:52:57 -04:00
if ( this . has _mode ) {
if ( disp . emoteOnly === true )
out . push ( this . t ( 'setting.actions.visible.emote-only' , 'when emote-only mode' ) ) ;
else if ( disp . emoteOnly === false )
out . push ( this . t ( 'setting.actions.visible.no-emote' , 'when not emote-only mode' ) ) ;
if ( disp . slowMode === true )
out . push ( this . t ( 'setting.actions.visible.slow' , 'when slow mode' ) ) ;
else if ( disp . slowMode === false )
out . push ( this . t ( 'setting.actions.visible.no-slow' , 'when not slow mode' ) ) ;
if ( disp . subsMode === true )
out . push ( this . t ( 'setting.actions.visible.subs' , 'when subs mode' ) ) ;
else if ( disp . subsMode === false )
out . push ( this . t ( 'setting.actions.visible.no-subs' , 'when not subs mode' ) ) ;
2019-08-27 16:18:12 -04:00
if ( disp . r9kMode === true )
out . push ( this . t ( 'setting.actions.visible.r9k' , 'when r9k mode' ) ) ;
else if ( disp . r9kMode === false )
out . push ( this . t ( 'setting.actions.visible.no-r9k' , 'when not r9k mode' ) ) ;
if ( disp . followersOnly === true )
out . push ( this . t ( 'setting.actions.visible.followers' , 'when followers-only mode' ) ) ;
else if ( disp . followersOnly === false )
out . push ( this . t ( 'setting.actions.visible.no-followers' , 'when not followers-only mode' ) ) ;
2019-08-12 22:52:57 -04:00
}
2019-05-16 14:46:26 -04:00
if ( disp . keys ) {
const key _out = [ ] ;
if ( disp . keys & 1 )
key _out . push ( this . t ( 'setting.key.ctrl' , 'Ctrl' ) ) ;
if ( disp . keys & 2 )
key _out . push ( this . t ( 'setting.key.shift' , 'Shift' ) ) ;
if ( disp . keys & 4 )
key _out . push ( this . t ( 'setting.key.alt' , 'Alt' ) ) ;
if ( disp . keys & 8 )
key _out . push ( this . t ( 'setting.key.meta' , 'Meta' ) ) ;
if ( key _out . length )
out . push ( this . t ( 'setting.actions.visible.modifier' , 'when {key_list} {keys, plural, one {is} other {are}} held' , {
key _list : key _out . join ( ' + ' ) ,
keys : key _out . length
} ) ) ;
}
2022-12-07 16:52:07 -05:00
if ( this . has _hover _modifier && disp . hover )
2020-08-13 14:00:47 -04:00
out . push ( this . t ( 'setting.actions.visible.hover' , 'when hovering' ) ) ;
2018-05-10 19:56:39 -04:00
if ( ! out . length )
return this . t ( 'setting.actions.visible.always' , 'always' ) ;
2018-04-28 17:56:03 -04:00
return out . join ( ', ' ) ;
}
} ,
methods : {
onChangeAction ( val ) {
for ( const key in val )
if ( has ( val , key ) ) {
const v = val [ key ] ;
if ( typeof v === 'string' && ! v . length )
delete val [ key ] ;
}
this . edit _data . options = val ;
} ,
2019-05-16 14:46:26 -04:00
onChangeKeys ( ) {
if ( ! this . editing )
return ;
let i = 0 ;
if ( this . $refs . key _ctrl . checked )
i |= 1 ;
if ( this . $refs . key _shift . checked )
i |= 2 ;
if ( this . $refs . key _alt . checked )
i |= 4 ;
if ( this . $refs . key _meta . checked )
i |= 8 ;
2020-08-13 14:00:47 -04:00
this . edit _data . display . hover = this . $refs . key _hover . checked ;
2019-05-16 14:46:26 -04:00
this . edit _data . display . keys = i ;
} ,
2018-04-28 17:56:03 -04:00
edit ( ) {
if ( ! this . canEdit )
return ;
this . editing = true ;
this . edit _data = deep _copy ( this . action . v ) ;
if ( ! this . edit _data . options )
this . edit _data . options = { } ;
if ( ! this . edit _data . display )
this . edit _data . display = { } ;
if ( ! this . edit _data . appearance )
this . edit _data . appearance = { } ;
} ,
save ( ) {
this . $emit ( 'save' , this . edit _data ) ;
this . cancel ( ) ;
} ,
2020-05-27 15:44:37 -04:00
prepareCopy ( ) {
this . copying = true ;
requestAnimationFrame ( ( ) => {
this . $refs . json . focus ( ) ;
} ) ;
} ,
2018-04-28 17:56:03 -04:00
cancel ( ) {
2020-05-27 15:44:37 -04:00
this . copying = false ;
2018-04-28 17:56:03 -04:00
this . editing = false ;
this . edit _data = null ;
} ,
2022-12-07 16:52:07 -05:00
maybeDynamic ( data ) {
let ap = data . appearance ;
if ( ap ? . type === 'dynamic' ) {
const act = this . action _def ,
ffz = this . vuectx . getFFZ ( ) ,
actions = ffz && ffz . resolve ( 'chat.actions' ) ;
const out = actions && act ? . dynamicAppearance && act . dynamicAppearance
. call ( actions , deep _copy ( ap ) , data , null , null , null , null ) ;
if ( out )
return Object . assign ( { } , data , { appearance : out } ) ;
}
return data ;
} ,
supportsRenderer ( key ) {
if ( key !== 'dynamic' )
return true ;
return this . action _def ? . supports _dynamic ;
} ,
2018-04-28 17:56:03 -04:00
getData ( ) {
const def = this . display && this . data . actions [ this . display . action ] ;
if ( ! def )
return ;
return Object . assign ( { } , this . display , {
options : Object . assign ( { } , def && def . defaults , this . display . options )
} )
}
}
}
< / script >