Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
Stable Diffusion Webui
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
novelai-storage
Stable Diffusion Webui
Commits
3a41d7c5
Commit
3a41d7c5
authored
Jun 14, 2023
by
Danil Boldyrev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Formatting code with Prettier
parent
9b687f01
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
95 additions
and
75 deletions
+95
-75
extensions-builtin/canvas-zoom-and-pan/javascript/zoom.js
extensions-builtin/canvas-zoom-and-pan/javascript/zoom.js
+95
-75
No files found.
extensions-builtin/canvas-zoom-and-pan/javascript/zoom.js
View file @
3a41d7c5
...
...
@@ -56,12 +56,13 @@ onUiLoaded(async() => {
}
}
// Check if hotkey is valid
function
isValidHotkey
(
value
)
{
const
specialKeys
=
[
"
Ctrl
"
,
"
Alt
"
,
"
Shift
"
,
"
Disable
"
];
return
(
(
typeof
value
===
"
string
"
&&
value
.
length
===
1
&&
/
[
a-z
]
/i
.
test
(
value
))
||
(
typeof
value
===
"
string
"
&&
value
.
length
===
1
&&
/
[
a-z
]
/i
.
test
(
value
))
||
specialKeys
.
includes
(
value
)
);
}
...
...
@@ -93,7 +94,8 @@ onUiLoaded(async() => {
typeof
userValue
===
"
object
"
||
userValue
===
"
disable
"
)
{
result
[
key
]
=
userValue
===
undefined
?
defaultValue
:
userValue
;
result
[
key
]
=
userValue
===
undefined
?
defaultValue
:
userValue
;
}
else
if
(
isValidHotkey
(
userValue
))
{
const
normalizedUserValue
=
normalizeHotkey
(
userValue
);
...
...
@@ -126,14 +128,21 @@ onUiLoaded(async() => {
return
result
;
}
// Disables functions in the config object based on the provided list of function names
function
disableFunctions
(
config
,
disabledFunctions
)
{
disabledFunctions
.
forEach
((
funcName
)
=>
{
if
(
functionMap
.
hasOwnProperty
(
funcName
))
{
// Bind the hasOwnProperty method to the functionMap object to avoid errors
const
hasOwnProperty
=
Object
.
prototype
.
hasOwnProperty
.
bind
(
functionMap
);
// Loop through the disabledFunctions array and disable the corresponding functions in the config object
disabledFunctions
.
forEach
(
funcName
=>
{
if
(
hasOwnProperty
(
funcName
))
{
const
key
=
functionMap
[
funcName
];
config
[
key
]
=
"
disable
"
;
}
});
// Return the updated config object
return
config
;
}
...
...
@@ -190,7 +199,7 @@ onUiLoaded(async() => {
canvas_hotkey_fullscreen
:
"
KeyS
"
,
canvas_hotkey_move
:
"
KeyF
"
,
canvas_hotkey_overlap
:
"
KeyO
"
,
canvas_disabled_functions
:
[],
canvas_disabled_functions
:
[],
canvas_show_tooltip
:
true
};
...
...
@@ -200,7 +209,7 @@ onUiLoaded(async() => {
"
Moving canvas
"
:
"
canvas_hotkey_move
"
,
"
Fullscreen
"
:
"
canvas_hotkey_fullscreen
"
,
"
Reset Zoom
"
:
"
canvas_hotkey_reset
"
,
"
Overlap
"
:
"
canvas_hotkey_overlap
"
,
"
Overlap
"
:
"
canvas_hotkey_overlap
"
};
// Loading the configuration from opts
...
...
@@ -274,24 +283,35 @@ onUiLoaded(async() => {
// Define an array with hotkey information and their actions
const
hotkeysInfo
=
[
{
configKey
:
"
canvas_hotkey_zoom
"
,
action
:
"
Zoom canvas
"
,
keySuffix
:
"
+ wheel
"
},
{
configKey
:
"
canvas_hotkey_adjust
"
,
action
:
"
Adjust brush size
"
,
keySuffix
:
"
+ wheel
"
},
{
configKey
:
"
canvas_hotkey_reset
"
,
action
:
"
Reset zoom
"
},
{
configKey
:
"
canvas_hotkey_fullscreen
"
,
action
:
"
Fullscreen mode
"
},
{
configKey
:
"
canvas_hotkey_move
"
,
action
:
"
Move canvas
"
},
{
configKey
:
"
canvas_hotkey_overlap
"
,
action
:
"
Overlap
"
},
{
configKey
:
"
canvas_hotkey_zoom
"
,
action
:
"
Zoom canvas
"
,
keySuffix
:
"
+ wheel
"
},
{
configKey
:
"
canvas_hotkey_adjust
"
,
action
:
"
Adjust brush size
"
,
keySuffix
:
"
+ wheel
"
},
{
configKey
:
"
canvas_hotkey_reset
"
,
action
:
"
Reset zoom
"
},
{
configKey
:
"
canvas_hotkey_fullscreen
"
,
action
:
"
Fullscreen mode
"
},
{
configKey
:
"
canvas_hotkey_move
"
,
action
:
"
Move canvas
"
},
{
configKey
:
"
canvas_hotkey_overlap
"
,
action
:
"
Overlap
"
}
];
// Create hotkeys array with disabled property based on the config values
const
hotkeys
=
hotkeysInfo
.
map
(
(
info
)
=>
{
const
hotkeys
=
hotkeysInfo
.
map
(
info
=>
{
const
configValue
=
hotkeysConfig
[
info
.
configKey
];
const
key
=
info
.
keySuffix
?
`
${
configValue
}${
info
.
keySuffix
}
`
:
configValue
.
charAt
(
configValue
.
length
-
1
);
const
key
=
info
.
keySuffix
?
`
${
configValue
}${
info
.
keySuffix
}
`
:
configValue
.
charAt
(
configValue
.
length
-
1
);
return
{
key
,
action
:
info
.
action
,
disabled
:
configValue
===
"
disable
"
,
disabled
:
configValue
===
"
disable
"
};
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment