From dd4ecbd4bafb2099cac32fcfdd267b82fe7bada2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Sat, 13 Jan 2024 20:35:22 +0100 Subject: [PATCH] Make the .hideIcon for Info and Where messages a button This implicitly fixes the cursor to properly show a pointer cursor. --- LICENSE | 2 +- .../js/Bastelstu.be/Chat/MessageType/Info.js | 27 ++++++++------- .../js/Bastelstu.be/Chat/MessageType/Where.js | 33 +++++++++++-------- 3 files changed, 36 insertions(+), 26 deletions(-) diff --git a/LICENSE b/LICENSE index 971fc7b..5e00f35 100644 --- a/LICENSE +++ b/LICENSE @@ -10,7 +10,7 @@ Additional Use Grant: You may use the Licensed Work when your application uses the Licensed Work for a purpose that does neither directly or indirectly generate revenue. -Change Date: 2027-02-22 +Change Date: 2028-01-13 Change License: Version 2 or later of the GNU General Public License as published by the Free Software Foundation. diff --git a/files_wcf/js/Bastelstu.be/Chat/MessageType/Info.js b/files_wcf/js/Bastelstu.be/Chat/MessageType/Info.js index 6708105..0432124 100644 --- a/files_wcf/js/Bastelstu.be/Chat/MessageType/Info.js +++ b/files_wcf/js/Bastelstu.be/Chat/MessageType/Info.js @@ -1,10 +1,10 @@ /* - * Copyright (c) 2010-2021 Tim Düsterhus. + * Copyright (c) 2010-2024 Tim Düsterhus. * * Use of this software is governed by the Business Source License * included in the LICENSE file. * - * Change Date: 2027-02-22 + * Change Date: 2028-01-13 * * On the date above, in accordance with the Business Source * License, use of this software will be governed by version 2 @@ -12,11 +12,10 @@ */ define([ - 'WoltLabSuite/Core/Dom/Traverse', 'WoltLabSuite/Core/Language', '../Helper', '../MessageType', -], function (DomTraverse, Language, Helper, MessageType) { +], function (Language, Helper, MessageType) { 'use strict' const decorators = Symbol('decorators') @@ -80,17 +79,23 @@ define([ }) ) - const icon = elCreate('span') - icon.classList.add('icon', 'icon16', 'fa-times', 'jsTooltip', 'hideIcon') - icon.setAttribute('title', Language.get('wcf.global.button.hide')) - icon.addEventListener('click', () => - elHide(DomTraverse.parentBySel(icon, '.chatMessageBoundary')) - ) + const button = document.createElement('button') + button.classList.add('button', 'small', 'jsTooltip', 'hideIcon') + button.setAttribute('title', Language.get('wcf.global.button.hide')) + + button.addEventListener('click', () => { + button.closest('.chatMessageBoundary').hidden = true + }) + + const icon = document.createElement('span') + icon.classList.add('icon', 'icon16', 'fa-times') + + button.append(icon) const elem = fragment.querySelector( '.chatMessage .containerList > li:first-child .containerHeadline' ) - elem.insertBefore(icon, elem.firstChild) + elem.insertBefore(button, elem.firstChild) return fragment } diff --git a/files_wcf/js/Bastelstu.be/Chat/MessageType/Where.js b/files_wcf/js/Bastelstu.be/Chat/MessageType/Where.js index 54ecd4e..cc995a7 100644 --- a/files_wcf/js/Bastelstu.be/Chat/MessageType/Where.js +++ b/files_wcf/js/Bastelstu.be/Chat/MessageType/Where.js @@ -1,36 +1,41 @@ /* - * Copyright (c) 2010-2021 Tim Düsterhus. + * Copyright (c) 2010-2024 Tim Düsterhus. * * Use of this software is governed by the Business Source License * included in the LICENSE file. * - * Change Date: 2027-02-22 + * Change Date: 2028-01-13 * * On the date above, in accordance with the Business Source * License, use of this software will be governed by version 2 * or later of the General Public License. */ -define([ - 'WoltLabSuite/Core/Dom/Traverse', - 'WoltLabSuite/Core/Language', - '../MessageType', -], function (DomTraverse, Language, MessageType) { +define(['WoltLabSuite/Core/Language', '../MessageType'], function ( + Language, + MessageType +) { 'use strict' class Where extends MessageType { render(message) { const fragment = super.render(message) - const icon = elCreate('span') - icon.classList.add('icon', 'icon16', 'fa-times', 'jsTooltip', 'hideIcon') - icon.setAttribute('title', Language.get('wcf.global.button.hide')) - icon.addEventListener('click', () => - elHide(DomTraverse.parentBySel(icon, '.chatMessageBoundary')) - ) + const button = document.createElement('button') + button.classList.add('button', 'small', 'jsTooltip', 'hideIcon') + button.setAttribute('title', Language.get('wcf.global.button.hide')) + + button.addEventListener('click', () => { + button.closest('.chatMessageBoundary').hidden = true + }) + + const icon = document.createElement('span') + icon.classList.add('icon', 'icon16', 'fa-times') + + button.append(icon) const elem = fragment.querySelector('.jsRoomInfo > .containerHeadline') - elem.insertBefore(icon, elem.firstChild) + elem.insertBefore(button, elem.firstChild) return fragment }