Skip to content

Commit f74cc0f

Browse files
committed
Fix compatibility with UI customizer
1 parent 93d9d57 commit f74cc0f

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

octoprint_inlineconfirm/static/js/inlineconfirm.js

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,35 @@ $(function () {
3030
}
3131

3232
var jobCancelOldText = '';
33+
var jobCancelButtonHasSpan = false
3334
self.jobCancel = InlineConfirm(
3435
'#state_wrapper .row-fluid.print-control button#job_cancel',
3536
self.printerStateModel.settings.feature_printCancelConfirmation,
3637
function () { OctoPrint.job.cancel(); },
3738
function (button, t) {
38-
$(button + ' > span').remove();
39-
$(button).textNodes().first().replaceWith(' Click again to confirm cancel <span>(' + t + ')</span>');
39+
if (jobCancelButtonHasSpan) {
40+
$(button + ' > span > span').remove();
41+
$(button + ' > span').html(' Click again to confirm cancel <span>(' + t + ')</span>');
42+
} else {
43+
$(button + ' > span').remove();
44+
$(button).textNodes().first().replaceWith(' Click again to confirm cancel <span>(' + t + ')</span>');
45+
}
4046
},
4147
function (button) {
42-
jobCancelOldText = $(button).textNodes().first().text();
48+
jobCancelButtonHasSpan = $(button).textNodes().first().length == 0
49+
if (jobCancelButtonHasSpan)
50+
jobCancelOldText = $(button + ' > span').html();
51+
else
52+
jobCancelOldText = $(button).textNodes().first().text();
4353
},
4454
function (button) {
45-
$(button).textNodes().first().replaceWith(jobCancelOldText);
46-
$(button + ' > span').remove();
55+
if (jobCancelButtonHasSpan) {
56+
$(button + ' > span').html(jobCancelOldText);
57+
}
58+
else {
59+
$(button).textNodes().first().replaceWith(jobCancelOldText);
60+
$(button + ' > span').remove();
61+
}
4762
}
4863
);
4964
var jobPrintOldText = '';

0 commit comments

Comments
 (0)