Skip to content

Commit 31abf57

Browse files
authored
Merge pull request #26 from drgrice1/remove-jquery-usage
Remove the last direct jquery usage of the renderer javascript.
2 parents 81bc463 + b65687b commit 31abf57

File tree

2 files changed

+33
-23
lines changed

2 files changed

+33
-23
lines changed

public/js/navbar.js

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,26 @@ for (const element of templateItems) {
2121
});
2222
}
2323

24-
$(function () {
25-
$('#hiddenSourceFilePath').text($('#sourceFilePath').val());
26-
$('#sourceFilePath').width($('#hiddenSourceFilePath').width());
27-
}).on('input', function () {
28-
$('#hiddenSourceFilePath').text($('#sourceFilePath').val());
29-
$('#sourceFilePath').width($('#hiddenSourceFilePath').width() + 12);
30-
const remaining =
31-
document.querySelector('.topnav').offsetWidth - document.querySelector('#template-select').offsetWidth - 330;
32-
$('#sourceFilePath').css('maxWidth', remaining);
24+
window.addEventListener('DOMContentLoaded', () => {
25+
const sourceFilePath = document.getElementById('sourceFilePath');
26+
const hiddenSourceFilePath = document.getElementById('hiddenSourceFilePath');
27+
if (!sourceFilePath || !hiddenSourceFilePath) return;
28+
29+
const adjustSourceWidth = () => {
30+
hiddenSourceFilePath.textContent = sourceFilePath.value;
31+
hiddenSourceFilePath.style.display = 'inline';
32+
sourceFilePath.style.width = `${hiddenSourceFilePath.offsetWidth + 12}px`;
33+
hiddenSourceFilePath.style.display = 'none';
34+
35+
const remaining =
36+
document.querySelector('.topnav').offsetWidth -
37+
document.querySelector('#template-select').offsetWidth -
38+
330;
39+
sourceFilePath.style.maxWidth = `${remaining}px`;
40+
};
41+
42+
sourceFilePath.addEventListener('input', adjustSourceWidth);
43+
adjustSourceWidth();
3344
});
3445

3546
let loadbutton = document.getElementById('load-problem');

templates/columns/editorUI.html.ep

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
%= javascript 'node_modules/@openwebwork/pg-codemirror-editor/dist/pg-codemirror-editor.js'
2-
%= javascript 'https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js'
32

43
<div id='edit-header' class='header'>
54
<b>Editing problem:</b><br>
@@ -24,22 +23,22 @@
2423
overflow: auto;
2524
background-color: white;
2625
height: 100%;
26+
}
2727

28-
.cm-editor {
29-
height: 100%;
28+
.code-mirror-editor .cm-editor {
29+
height: 100%;
30+
}
3031

31-
.cm-scroller {
32-
height: 100%;
32+
.code-mirror-editor .cm-editor .cm-scroller {
33+
height: 100%;
34+
}
3335

34-
.cm-content {
35-
height: 100%;
36-
min-height: 400px;
37-
}
38-
}
36+
.code-mirror-editor .cm-editor .cm-scroller .cm-content {
37+
height: 100%;
38+
min-height: 400px;
39+
}
3940

40-
.cm-panels {
41-
z-index: 18;
42-
}
43-
}
41+
.code-mirror-editor .cm-editor .cm-panels {
42+
z-index: 18;
4443
}
4544
% end

0 commit comments

Comments
 (0)