Skip to content

Commit ca89679

Browse files
committed
remove jQuery usage
1 parent df28f31 commit ca89679

File tree

3 files changed

+25
-16
lines changed

3 files changed

+25
-16
lines changed

.eslintrc.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ module.exports = {
22
extends: [
33
'@nextcloud',
44
],
5-
globals: {
6-
$: 'readonly',
7-
},
85
rules: {
96
// no ending html tag on a new line (was warn in "vue/strongly-recommended")
107
'vue/html-closing-bracket-newline': ['error', { multiline: 'always' }],

src/components/EditorEasyMDE.vue

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,26 +60,29 @@ export default {
6060
this.mde.codemirror.on('change', () => {
6161
this.$emit('input', this.mde.value())
6262
})
63-
this.initializeCheckboxes()
63+
64+
document.querySelectorAll('.CodeMirror-code').forEach((codeElement) => {
65+
codeElement.addEventListener('mousedown', this.onClickCodeElement)
66+
codeElement.addEventListener('touchstart', this.onClickCodeElement)
67+
})
6468
},
6569
66-
initializeCheckboxes() {
67-
// TODO move the following from jQuery to plain JS
68-
$('.CodeMirror-code').on('mousedown.checkbox touchstart.checkbox', '.cm-formatting-task', event => {
70+
onClickCodeElement(event) {
71+
const element = event.target.closest('.cm-formatting-task')
72+
if (element !== null) {
6973
event.preventDefault()
7074
event.stopImmediatePropagation()
7175
this.toggleCheckbox(event.target)
72-
})
76+
}
7377
},
7478
7579
toggleCheckbox(el) {
76-
// TODO move the following from jQuery to plain JS
77-
const $el = $(el)
7880
const doc = this.mde.codemirror.getDoc()
79-
const index = $el.parents('.CodeMirror-line').index()
81+
const domLine = el.closest('.CodeMirror-line')
82+
const index = [].indexOf.call(domLine.parentElement.children, domLine)
8083
const line = doc.getLineHandle(index)
8184
82-
const newvalue = ($el.text() === '[x]') ? '[ ]' : '[x]'
85+
const newvalue = (el.textContent === '[x]') ? '[ ]' : '[x]'
8386
8487
// + 1 for some reason... not sure why
8588
doc.replaceRange(newvalue,

src/components/Note.vue

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,17 @@ export default {
126126
127127
created() {
128128
this.fetchData()
129-
// TODO move the following from jQuery to plain JS
130-
$(document).bind('webkitfullscreenchange mozfullscreenchange fullscreenchange', this.onDetectFullscreen)
131-
$(document).bind('keypress.notes.save', this.onKeyPress)
129+
document.addEventListener('webkitfullscreenchange', this.onDetectFullscreen)
130+
document.addEventListener('mozfullscreenchange', this.onDetectFullscreen)
131+
document.addEventListener('fullscreenchange', this.onDetectFullscreen)
132+
document.addEventListener('keydown', this.onKeyPress)
132133
},
133134
134135
destroyed() {
135-
$(document).unbind('keypress.notes.save')
136+
document.removeEventListener('webkitfullscreenchange', this.onDetectFullscreen)
137+
document.removeEventListener('mozfullscreenchange', this.onDetectFullscreen)
138+
document.removeEventListener('fullscreenchange', this.onDetectFullscreen)
139+
document.removeEventListener('keydown', this.onKeyPress)
136140
store.commit('setSidebarOpen', false)
137141
this.onUpdateTitle(null)
138142
},
@@ -246,6 +250,11 @@ export default {
246250
},
247251
248252
onManualSave() {
253+
const note = {
254+
...this.note,
255+
autotitle: routeIsNewNote(this.$route),
256+
}
257+
store.commit('add', note)
249258
saveNoteManually(this.note.id)
250259
},
251260
},

0 commit comments

Comments
 (0)