From 8d4e2249d01d774c19662f112301695923e48a4b Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Willms <tleilax+studip@gmail.com> Date: Thu, 28 Nov 2024 11:03:20 +0100 Subject: [PATCH] fixes #3 --- assets/script.js | 108 ++++++++++++++++++++++++----------------------- plugin.manifest | 2 +- 2 files changed, 56 insertions(+), 54 deletions(-) diff --git a/assets/script.js b/assets/script.js index 8acf579..0fb6b44 100644 --- a/assets/script.js +++ b/assets/script.js @@ -1,64 +1,66 @@ (function (STUDIP) { 'use strict'; - let app = null; - - STUDIP.Vue.load().then(({createApp}) => { - app = createApp({ - data () { - return { - color: 'blue', - needle: '', - size: 32, - source: STUDIP.IconOverview - }; - }, - methods: { - iconPath (icon) { - return `${STUDIP.ASSETS_URL}images/icons/${this.color}/${icon.icon}.svg`; + STUDIP.ready(() => { + STUDIP.Vue.load().then(({createApp}) => { + app = createApp({ + data () { + return { + color: 'blue', + needle: '', + size: 32, + source: STUDIP.IconOverview + }; }, - search (needle) { - this.needle = needle; - } - }, - computed: { - icons () { - if (!this.needle.length) { - return this.source; + methods: { + iconPath (icon) { + return `${STUDIP.ASSETS_URL}images/icons/${this.color}/${icon.icon}.svg`; + }, + search (needle) { + this.needle = needle; } - return this.source.filter(icon => { - return icon.icon.toLocaleLowerCase().includes(this.needle.toLocaleLowerCase()) - || icon.title?.toLocaleLowerCase().includes(this.needle.toLocaleLowerCase()); - }); - } - } - }); - app.$mount('#icon-overview'); - }); - - STUDIP.ready(() => { - $('#icon-search :input').keyup(event => { - const needle = event.target.value.trim(); - if (app !== null) { - app.search(needle); - } - - event.stopPropagation(); - event.preventDefault(); - }); - - $('#icon-options select[name="color"]').removeClass('submit-upon-select').change(event => { - app.color = event.target.value; + }, + computed: { + icons () { + if (!this.needle.length) { + return this.source; + } + return this.source.filter(icon => { + return icon.icon.toLocaleLowerCase().includes(this.needle.toLocaleLowerCase()) + || icon.title?.toLocaleLowerCase().includes(this.needle.toLocaleLowerCase()); + }); + } + }, + created() { + document.querySelector('#icon-search input').addEventListener( + 'keyup', + (event) => { + this.needle = event.target.value.trim(); + event.preventDefault(); + event.stopPropagation(); + } + ) + document.querySelector('#icon-options select[name="color"]').addEventListener( + 'change', + (event) => { + this.color = event.target.value; - event.stopPropagation(); - event.preventDefault(); - }); + event.stopPropagation(); + event.preventDefault(); + } + ); - $('#icon-options select[name="size"]').removeClass('submit-upon-select').change(event => { - app.size = event.target.value; + document.querySelector('#icon-options select[name="size"]').addEventListener( + 'change', + (event) => { + this.size = Number.parseInt(event.target.value, 10); - event.stopPropagation(); - event.preventDefault(); + event.stopPropagation(); + event.preventDefault(); + } + ); + } + }).$mount('#icon-overview'); }); }) }(STUDIP)); diff --git a/plugin.manifest b/plugin.manifest index f869898..34aeb95 100644 --- a/plugin.manifest +++ b/plugin.manifest @@ -1,5 +1,5 @@ pluginname=Icon overview pluginclassname=IconOverview -version=1.1 +version=1.2 origin=UOL studipMinVersion=5.0 -- GitLab