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
2fc2fbb4
Commit
2fc2fbb4
authored
May 27, 2023
by
AUTOMATIC1111
Committed by
GitHub
May 27, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #10708 from akx/on-ui-update-throttled
Add onAfterUiUpdate callback
parents
5d29672b
dc7a1bbb
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
65 additions
and
21 deletions
+65
-21
.eslintrc.js
.eslintrc.js
+4
-3
javascript/aspectRatioOverlay.js
javascript/aspectRatioOverlay.js
+1
-1
javascript/contextMenus.js
javascript/contextMenus.js
+1
-3
javascript/generationParams.js
javascript/generationParams.js
+1
-1
javascript/imageMaskFix.js
javascript/imageMaskFix.js
+1
-1
javascript/imageviewer.js
javascript/imageviewer.js
+1
-1
javascript/notification.js
javascript/notification.js
+1
-1
javascript/ui.js
javascript/ui.js
+1
-1
script.js
script.js
+54
-9
No files found.
.eslintrc.js
View file @
2fc2fbb4
...
...
@@ -50,13 +50,14 @@ module.exports = {
globals
:
{
//script.js
gradioApp
:
"
readonly
"
,
executeCallbacks
:
"
readonly
"
,
onAfterUiUpdate
:
"
readonly
"
,
onOptionsChanged
:
"
readonly
"
,
onUiLoaded
:
"
readonly
"
,
onUiUpdate
:
"
readonly
"
,
onOptionsChanged
:
"
readonly
"
,
uiCurrentTab
:
"
writable
"
,
uiElementIsVisible
:
"
readonly
"
,
uiElementInSight
:
"
readonly
"
,
executeCallbacks
:
"
readonly
"
,
uiElementIsVisible
:
"
readonly
"
,
//ui.js
opts
:
"
writable
"
,
all_gallery_buttons
:
"
readonly
"
,
...
...
javascript/aspectRatioOverlay.js
View file @
2fc2fbb4
...
...
@@ -81,7 +81,7 @@ function dimensionChange(e, is_width, is_height) {
}
onUiUpdate
(
function
()
{
on
After
UiUpdate
(
function
()
{
var
arPreviewRect
=
gradioApp
().
querySelector
(
'
#imageARPreview
'
);
if
(
arPreviewRect
)
{
arPreviewRect
.
style
.
display
=
'
none
'
;
...
...
javascript/contextMenus.js
View file @
2fc2fbb4
...
...
@@ -167,6 +167,4 @@ var addContextMenuEventListener = initResponse[2];
})();
//End example Context Menu Items
onUiUpdate
(
function
()
{
addContextMenuEventListener
();
});
onAfterUiUpdate
(
addContextMenuEventListener
);
javascript/generationParams.js
View file @
2fc2fbb4
// attaches listeners to the txt2img and img2img galleries to update displayed generation param text when the image changes
let
txt2img_gallery
,
img2img_gallery
,
modal
=
undefined
;
onUiUpdate
(
function
()
{
on
After
UiUpdate
(
function
()
{
if
(
!
txt2img_gallery
)
{
txt2img_gallery
=
attachGalleryListeners
(
"
txt2img
"
);
}
...
...
javascript/imageMaskFix.js
View file @
2fc2fbb4
...
...
@@ -39,5 +39,5 @@ function imageMaskResize() {
});
}
onUiUpdate
(
imageMaskResize
);
on
After
UiUpdate
(
imageMaskResize
);
window
.
addEventListener
(
'
resize
'
,
imageMaskResize
);
javascript/imageviewer.js
View file @
2fc2fbb4
...
...
@@ -170,7 +170,7 @@ function modalTileImageToggle(event) {
event
.
stopPropagation
();
}
onUiUpdate
(
function
()
{
on
After
UiUpdate
(
function
()
{
var
fullImg_preview
=
gradioApp
().
querySelectorAll
(
'
.gradio-gallery > div > img
'
);
if
(
fullImg_preview
!=
null
)
{
fullImg_preview
.
forEach
(
setupImageForLightbox
);
...
...
javascript/notification.js
View file @
2fc2fbb4
...
...
@@ -4,7 +4,7 @@ let lastHeadImg = null;
let
notificationButton
=
null
;
onUiUpdate
(
function
()
{
on
After
UiUpdate
(
function
()
{
if
(
notificationButton
==
null
)
{
notificationButton
=
gradioApp
().
getElementById
(
'
request_notifications
'
);
...
...
javascript/ui.js
View file @
2fc2fbb4
...
...
@@ -249,7 +249,7 @@ function confirm_clear_prompt(prompt, negative_prompt) {
var
opts
=
{};
onUiUpdate
(
function
()
{
on
After
UiUpdate
(
function
()
{
if
(
Object
.
keys
(
opts
).
length
!=
0
)
return
;
var
json_elem
=
gradioApp
().
getElementById
(
'
settings_json
'
);
...
...
script.js
View file @
2fc2fbb4
...
...
@@ -19,35 +19,79 @@ function get_uiCurrentTabContent() {
}
var
uiUpdateCallbacks
=
[];
var
uiAfterUpdateCallbacks
=
[];
var
uiLoadedCallbacks
=
[];
var
uiTabChangeCallbacks
=
[];
var
optionsChangedCallbacks
=
[];
var
uiAfterUpdateTimeout
=
null
;
var
uiCurrentTab
=
null
;
/**
* Register callback to be called at each UI update.
* The callback receives an array of MutationRecords as an argument.
*/
function
onUiUpdate
(
callback
)
{
uiUpdateCallbacks
.
push
(
callback
);
}
/**
* Register callback to be called soon after UI updates.
* The callback receives no arguments.
*
* This is preferred over `onUiUpdate` if you don't need
* access to the MutationRecords, as your function will
* not be called quite as often.
*/
function
onAfterUiUpdate
(
callback
)
{
uiAfterUpdateCallbacks
.
push
(
callback
);
}
/**
* Register callback to be called when the UI is loaded.
* The callback receives no arguments.
*/
function
onUiLoaded
(
callback
)
{
uiLoadedCallbacks
.
push
(
callback
);
}
/**
* Register callback to be called when the UI tab is changed.
* The callback receives no arguments.
*/
function
onUiTabChange
(
callback
)
{
uiTabChangeCallbacks
.
push
(
callback
);
}
/**
* Register callback to be called when the options are changed.
* The callback receives no arguments.
* @param callback
*/
function
onOptionsChanged
(
callback
)
{
optionsChangedCallbacks
.
push
(
callback
);
}
function
runCallback
(
x
,
m
)
{
try
{
x
(
m
);
}
catch
(
e
)
{
(
console
.
error
||
console
.
log
).
call
(
console
,
e
.
message
,
e
);
function
executeCallbacks
(
queue
,
arg
)
{
for
(
const
callback
of
queue
)
{
try
{
callback
(
arg
);
}
catch
(
e
)
{
console
.
error
(
"
error running callback
"
,
callback
,
"
:
"
,
e
);
}
}
}
function
executeCallbacks
(
queue
,
m
)
{
queue
.
forEach
(
function
(
x
)
{
runCallback
(
x
,
m
);
});
/**
* Schedule the execution of the callbacks registered with onAfterUiUpdate.
* The callbacks are executed after a short while, unless another call to this function
* is made before that time. IOW, the callbacks are executed only once, even
* when there are multiple mutations observed.
*/
function
scheduleAfterUiUpdateCallbacks
()
{
clearTimeout
(
uiAfterUpdateTimeout
);
uiAfterUpdateTimeout
=
setTimeout
(
function
()
{
executeCallbacks
(
uiAfterUpdateCallbacks
);
},
200
);
}
var
executedOnLoaded
=
false
;
...
...
@@ -60,6 +104,7 @@ document.addEventListener("DOMContentLoaded", function() {
}
executeCallbacks
(
uiUpdateCallbacks
,
m
);
scheduleAfterUiUpdateCallbacks
();
const
newTab
=
get_uiCurrentTab
();
if
(
newTab
&&
(
newTab
!==
uiCurrentTab
))
{
uiCurrentTab
=
newTab
;
...
...
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