Skip to content

Commit

Permalink
Remove renaming of "this" in JS class
Browse files Browse the repository at this point in the history
  • Loading branch information
Splines committed Oct 22, 2023
1 parent 735585f commit 759d99c
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions app/assets/javascripts/thyme/display_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,50 +38,48 @@ class DisplayManager {

// Check screen size and trigger the right method
updateControlBarType() {
const dm = this;

if (window.matchMedia("screen and (max-width: " +
thymeAttributes.hideControlBarThreshold.x + "px)").matches ||
window.matchMedia("screen and (max-height: " +
thymeAttributes.hideControlBarThreshold.y + "px)").matches) {
dm.adaptToSmallDisplay();
this.adaptToSmallDisplay();
}

if (window.matchMedia("screen and (max-device-width: " +
thymeAttributes.hideControlBarThreshold.x + "px)").matches ||
window.matchMedia("screen and (max-device-height: " +
thymeAttributes.hideControlBarThreshold.y + "px)").matches) {
dm.adaptToSmallDisplay();
this.adaptToSmallDisplay();
}

// mediaQuery listener for very small screens
const matchVerysmallX = window.matchMedia("screen and (max-width: " +
thymeAttributes.hideControlBarThreshold.x + "px)");
matchVerysmallX.addListener(function (result) {
if (result.matches) {
dm.adaptToSmallDisplay();
this.adaptToSmallDisplay();
}
});
const matchVerysmallY = window.matchMedia("screen and (max-height: " +
thymeAttributes.hideControlBarThreshold.y + "px)");
matchVerysmallY.addListener(function (result) {
if (result.matches) {
dm.adaptToSmallDisplay();
this.adaptToSmallDisplay();
}
});

const matchVerysmalldeviceX = window.matchMedia("screen and (max-device-width: " +
thymeAttributes.hideControlBarThreshold.x + "px)");
matchVerysmalldeviceX.addListener(function (result) {
if (result.matches) {
dm.adaptToSmallDisplay();
this.adaptToSmallDisplay();
}
});
const matchVerysmalldeviceY = window.matchMedia("screen and (max-device-height: " +
thymeAttributes.hideControlBarThreshold.y + "px)");
matchVerysmalldeviceY.addListener(function (result) {
if (result.matches) {
dm.adaptToSmallDisplay();
this.adaptToSmallDisplay();
}
});

Expand All @@ -93,7 +91,7 @@ class DisplayManager {
matchNormalY = window.matchMedia("screen and (min-height: " +
(thymeAttributes.hideControlBarThreshold.y + 1) + "px)");
if (result.matches && matchNormalY.matches) {
dm.adaptToLargeDisplay();
this.adaptToLargeDisplay();
}
});
const matchNormalY = window.matchMedia("screen and (min-height: " +
Expand All @@ -102,7 +100,7 @@ class DisplayManager {
matchNormalX = window.matchMedia("screen and (min-width: " +
(thymeAttributes.hideControlBarThreshold.x + 1) + "px)");
if (result.matches && matchNormalX.matches) {
dm.adaptToLargeDisplay();
this.adaptToLargeDisplay();
}
});

Expand All @@ -113,7 +111,7 @@ class DisplayManager {
matchNormaldeviceY = window.matchMedia("screen and (min-device-height: " +
(thymeAttributes.hideControlBarThreshold.y + 1) + "px)");
if (result.matches && matchNormalY.matches) {
dm.adaptToLargeDisplay();
this.adaptToLargeDisplay();
}
});
matchNormaldeviceY = window.matchMedia("screen and (min-device-height: " +
Expand All @@ -122,7 +120,7 @@ class DisplayManager {
matchNormaldeviceX = window.matchMedia("screen and (min-device-width: " +
(thymeAttributes.hideControlBarThreshold.x + 1) + "px)");
if (result.matches && matchNormalX.matches) {
dm.adaptToLargeDisplay();
this.adaptToLargeDisplay();
}
});
}
Expand Down

0 comments on commit 759d99c

Please sign in to comment.