Skip to content

Commit

Permalink
🐛 Fix Webcam w/ OctoPrint 1.3.3
Browse files Browse the repository at this point in the history
Fix new webcam
  • Loading branch information
BillyBlaze committed May 21, 2017
1 parent 853c71d commit 6526a33
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 31 deletions.
2 changes: 1 addition & 1 deletion octoprint_touchui/static/css/touchui.css

Large diffs are not rendered by default.

38 changes: 22 additions & 16 deletions octoprint_touchui/static/js/touchui.bundled.js
Original file line number Diff line number Diff line change
Expand Up @@ -1136,10 +1136,13 @@ TouchUI.prototype.knockout.isLoading = function (viewModels) {
self.components.touchscreen.isLoading.call(self, viewModels);

// Reload dimensions of webcam with onload event
// Legacy code from 1.3.3
// Fixes bug #78
$("#webcam_image").on("load", function() {
viewModels.controlViewModel.updateRotatorWidth();
});
if(viewModels.controlViewModel && viewModels.controlViewModel.updateRotatorWidth) {
$("#webcam_image").on("load", function() {
viewModels.controlViewModel.updateRotatorWidth();
});
}

// Prevent user from double clicking in a short period on buttons
$(document).on("click", "button:not(#login_button, .box, .distance, .dropdown-toggle)", function(e) {
Expand Down Expand Up @@ -1211,9 +1214,12 @@ TouchUI.prototype.knockout.isReady = function (viewModels) {
});

// Remove drag files into website feature
$(document).off("drag");
$(document).off("dragover");
if(viewModels.gcodeFilesViewModel._enableDragNDrop) {
if(viewModels.gcodeFilesViewModel && viewModels.gcodeFilesViewModel._enableDragNDrop) {
viewModels.gcodeFilesViewModel._enableDragNDrop(false);
viewModels.gcodeFilesViewModel._enableDragNDrop = function() {};
viewModels.gcodeFilesViewModel._forceEndDragNDrop = function() {};
}

// Hide the dropdown after login
Expand Down Expand Up @@ -1472,18 +1478,18 @@ TouchUI.prototype.plugins.screenSquish = function(pluginManagerViewModel) {

};

TouchUI.prototype.plugins.tempsGraph = function() {

_.remove(OCTOPRINT_VIEWMODELS, function(obj) {
if (obj[0] && obj[0].name === "TempsgraphViewModel") {
console.info("TouchUI: TempsGraph is disabled while TouchUI is active.");
return true;
}

return false;
});

}
TouchUI.prototype.plugins.tempsGraph = function() {

_.remove(OCTOPRINT_VIEWMODELS, function(obj) {
if (obj[0] && obj[0].name === "TempsgraphViewModel") {
console.info("TouchUI: TempsGraph is disabled while TouchUI is active.");
return true;
}

return false;
});

}

TouchUI.prototype.scroll.beforeLoad = function() {

Expand Down
22 changes: 17 additions & 5 deletions octoprint_touchui/static/less/touchui.bundled.less
Original file line number Diff line number Diff line change
Expand Up @@ -2456,13 +2456,14 @@ min-height: 100%;
background: @main-background;
color: @text-color;
position: relative;
*:not(.fa) {
* {
font-family: 'Source Code Pro', monospace;
.text-shadow(none) !important; .box-shadow(none) !important; }
.no-pointer * {
pointer-events: none !important;
}
[class^="icon-"], [class*=" icon-"] {
[class^="icon-"], [class*=" icon-"],
[class^="fa-"], [class*=" fa-"] {
font-family: FontAwesome !important;
}
#navbar {
Expand Down Expand Up @@ -3042,12 +3043,18 @@ opacity: 0 !important;
}
#webcam {
margin: (-@main-gutter + 1px) -@main-gutter 0;
#webcam_rotator {
#webcam_rotator,
#webcam_rotator .webcam_fixed_ratio .webcam_fixed_ratio_inner {
display: flex;
align-content: center;
align-items: center;
justify-content: center;
}
#webcam_rotator .webcam_fixed_ratio {
padding: 0;
height: 100%;
width: 100%;
}
#webcam_image {
display: block;
width: 100%;
Expand All @@ -3057,7 +3064,8 @@ height: auto;
padding: 35px;
display: block;
}
.rotate90 {
.rotate90,
.webcam_rotated .webcam_fixed_ratio {
transform: rotate(0deg) !important;
height: auto;
#webcam_image {
Expand All @@ -3074,8 +3082,12 @@ transform: rotate(-90deg) scaleY(-1) scaleX(-1) !important;
}
}
}
.webcam_rotated .webcam_fixed_ratio {
padding: 0;
}
@supports (object-fit: contain) {
#webcam_rotator {
#webcam_rotator,
#webcam_rotator .webcam_fixed_ratio .webcam_fixed_ratio_inner {
height: ~"calc(100vh - 69px)";
}
#webcam_image {
Expand Down
9 changes: 6 additions & 3 deletions source/js/knockout/isLoading.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ TouchUI.prototype.knockout.isLoading = function (viewModels) {
self.components.touchscreen.isLoading.call(self, viewModels);

// Reload dimensions of webcam with onload event
// Legacy code from 1.3.3
// Fixes bug #78
$("#webcam_image").on("load", function() {
viewModels.controlViewModel.updateRotatorWidth();
});
if(viewModels.controlViewModel && viewModels.controlViewModel.updateRotatorWidth) {
$("#webcam_image").on("load", function() {
viewModels.controlViewModel.updateRotatorWidth();
});
}

// Prevent user from double clicking in a short period on buttons
$(document).on("click", "button:not(#login_button, .box, .distance, .dropdown-toggle)", function(e) {
Expand Down
5 changes: 4 additions & 1 deletion source/js/knockout/isReady.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@ TouchUI.prototype.knockout.isReady = function (viewModels) {
});

// Remove drag files into website feature
$(document).off("drag");
$(document).off("dragover");
if(viewModels.gcodeFilesViewModel._enableDragNDrop) {
if(viewModels.gcodeFilesViewModel && viewModels.gcodeFilesViewModel._enableDragNDrop) {
viewModels.gcodeFilesViewModel._enableDragNDrop(false);
viewModels.gcodeFilesViewModel._enableDragNDrop = function() {};
viewModels.gcodeFilesViewModel._forceEndDragNDrop = function() {};
}

// Hide the dropdown after login
Expand Down
18 changes: 15 additions & 3 deletions source/less/tabs/webcam.less
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
#webcam {
margin: (-@main-gutter + 1px) -@main-gutter 0;

#webcam_rotator {
#webcam_rotator,
#webcam_rotator .webcam_fixed_ratio .webcam_fixed_ratio_inner {
display: flex;
align-content: center;
align-items: center;
justify-content: center;
}

#webcam_rotator .webcam_fixed_ratio {
padding: 0;
height: 100%;
width: 100%;
}

#webcam_image {
display: block;
width: 100%;
Expand All @@ -19,7 +26,8 @@
display: block;
}

.rotate90 {
.rotate90,
.webcam_rotated .webcam_fixed_ratio {
transform: rotate(0deg) !important;
height: auto;

Expand All @@ -38,9 +46,13 @@
}
}
}
.webcam_rotated .webcam_fixed_ratio {
padding: 0;
}

@supports (object-fit: contain) {
#webcam_rotator {
#webcam_rotator,
#webcam_rotator .webcam_fixed_ratio .webcam_fixed_ratio_inner {
height: ~"calc(100vh - 69px)";
}

Expand Down
5 changes: 3 additions & 2 deletions source/less/touchui.less
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
color: @text-color;
position: relative;

*:not(.fa) {
* {
font-family: 'Source Code Pro', monospace;
.text-shadow(none) !important; /* This should increase performance */
.box-shadow(none) !important; /* This should increase performance */
Expand All @@ -35,7 +35,8 @@
pointer-events: none !important;
}

[class^="icon-"], [class*=" icon-"] {
[class^="icon-"], [class*=" icon-"],
[class^="fa-"], [class*=" fa-"] {
font-family: FontAwesome !important;
}

Expand Down

0 comments on commit 6526a33

Please sign in to comment.