From 78dd50ffb12a95982cd49dd7f95d8e3e14ee6223 Mon Sep 17 00:00:00 2001 From: ntoff Date: Wed, 5 Dec 2018 16:27:51 +1000 Subject: [PATCH] add dynamic button title hover info Add the lock/unlocked state to the lock buttn's title hover for state clarity --- octoprint_fanspeedslider/static/js/fanslider.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/octoprint_fanspeedslider/static/js/fanslider.js b/octoprint_fanspeedslider/static/js/fanslider.js index ca58c27..f77a879 100644 --- a/octoprint_fanspeedslider/static/js/fanslider.js +++ b/octoprint_fanspeedslider/static/js/fanslider.js @@ -19,6 +19,8 @@ $(function () { self.settings.notifyDelay = new ko.observable(4000); //time in milliseconds self.settings.lockfan = new ko.observable(false); //ignore fan inputs from gcode and lock the fan buttons + self.control.lockTitle = new ko.observable(gettext("Unlocked")); //will set the hover title info for the fan lock button + //Not sure why I put these here, I swear I had a plan when I did it, something about dynamic text? I dunno, should move it back to the settings page self.settings.commonTitle = ko.observable(gettext("\n\nThis allows limiting the cooling fan without having to re-slice your model.\n\nLimited to prints controlled by OctoPrint.")); self.settings.defaultTitle = ko.observable(gettext("This is the value the slider will default to when the UI is loaded / refreshed.")); @@ -111,7 +113,9 @@ $(function () { \
\ \ - \ + \
\ "); } else { @@ -124,7 +128,9 @@ $(function () { $("#control-jog-feedrate").append("\ \ \ - \ + \ "); } } @@ -138,6 +144,13 @@ $(function () { self.settings.maxFanSpeed(parseInt(self.settings.settings.plugins.fanspeedslider.maxSpeed())); self.settings.notifyDelay(parseInt(self.settings.settings.plugins.fanspeedslider.notifyDelay())); self.settings.lockfan(self.settings.settings.plugins.fanspeedslider.lockfan()); + + if (self.settings.lockfan()) { + self.control.lockTitle( gettext("Lock or unlock the cooling fan controls. When locked, no cooling fan commands will be sent to the printer. \n\n Fan controls are locked.")); + } + else if (!self.settings.lockfan()) { + self.control.lockTitle( gettext("Lock or unlock the cooling fan controls. When locked, no cooling fan commands will be sent to the printer. \n\n Fan controls are unlocked")) + } } catch (error) { console.log(error);