Skip to content

Commit

Permalink
🎨 Close dialogs by clicking outside
Browse files Browse the repository at this point in the history
OctoPrint has this option to prevent clicking outside
of dialogs; If TouchUI is active we will set this
by default to true. An user can override this in the
settings menu of TouchUI.
  • Loading branch information
BillyBlaze committed Mar 11, 2020
1 parent 2527b92 commit 978cdbf
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 2 deletions.
3 changes: 2 additions & 1 deletion octoprint_touchui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import os

try:
from octoprint.access.permissions import ADMIN_GROUP, USER_GROUP
from octoprint.access.permissions import ADMIN_GROUP
except:
ADMIN_GROUP=None
USER_GROUP=None
Expand Down Expand Up @@ -91,6 +91,7 @@ def get_settings_defaults(self):
automaticallyLoadResolution=True,
automaticallyLoadTouch=True,
useCustomization=False,
closeDialogsOutside=False,
colors=dict(
mainColor="#00B0FF",
termColor="#0F0",
Expand Down
2 changes: 1 addition & 1 deletion octoprint_touchui/static/css/touchui.css

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions octoprint_touchui/static/js/touchui.bundled.js
Original file line number Diff line number Diff line change
Expand Up @@ -1434,6 +1434,11 @@ TouchUI.prototype.knockout.isReady = function (viewModels) {
setTimeout(function() {
self.plugins.multiWebCam.call(self);
}, 0);

// Disable clicking outside models
viewModels.settingsViewModel.appearance_closeModalsWithClick(this.settings.closeDialogsOutside());
$('#settings-appearanceCloseModalsWithClick').parent().addClass('touchui_disabled');
$('<span>(Disabled and managed by TouchUI)</span>').appendTo($('#settings-appearanceCloseModalsWithClick').parent());
}
}

Expand Down
7 changes: 7 additions & 0 deletions octoprint_touchui/static/less/touchui.bundled.less
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,13 @@ div.error {
background: transparent !important;
color: inherit !important;
}
.touchui_disabled {
opacity: 0.7;
pointer-events: none;
}
#settings-appearanceCloseModalsWithClick span {
font-size: 11px;
}
#navbar {
background-color: @main-color;
border: 0 none !important;
Expand Down
6 changes: 6 additions & 0 deletions octoprint_touchui/templates/touchui_settings.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
</label>
</div>

<div class="controls">
<label class="checkbox">
<input type="checkbox" data-bind="checked: settings.closeDialogsOutside"> Close dialogs by clicking outside
</label>
</div>

</div>

<div class="control-group" data-bind="css: { disabled: !settings.useCustomization() }">
Expand Down
7 changes: 7 additions & 0 deletions source/js/knockout/isReady.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,5 +174,12 @@ TouchUI.prototype.knockout.isReady = function (viewModels) {
setTimeout(function() {
self.plugins.multiWebCam.call(self);
}, 0);

// Disable clicking outside models
if (viewModels.settingsViewModel.appearance_closeModalsWithClick) {
viewModels.settingsViewModel.appearance_closeModalsWithClick(this.settings.closeDialogsOutside());
$('#settings-appearanceCloseModalsWithClick').parent().addClass('touchui_disabled');
$('<span>(Disabled and managed by TouchUI)</span>').appendTo($('#settings-appearanceCloseModalsWithClick').parent());
}
}
}
9 changes: 9 additions & 0 deletions source/less/touchui.less
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@
color: inherit !important;
}

.touchui_disabled {
opacity: 0.7;
pointer-events: none;
}

#settings-appearanceCloseModalsWithClick span {
font-size: 11px;
}

@import "layout/header.less";
@import "layout/general.less";
@import "layout/links.less";
Expand Down

0 comments on commit 978cdbf

Please sign in to comment.