From e6dd1b2bb657dabd08acd5602f0e2593b6ff5d03 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Sun, 20 Aug 2023 16:59:13 +0900 Subject: [PATCH] Fix compatibility with communication module skins that don't support window_type=self --- modules/communication/communication.view.php | 18 ++++++++++++++++ modules/communication/tpl/js/window_type.js | 22 ++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 modules/communication/tpl/js/window_type.js diff --git a/modules/communication/communication.view.php b/modules/communication/communication.view.php index 53cfd970e..1170d9f82 100644 --- a/modules/communication/communication.view.php +++ b/modules/communication/communication.view.php @@ -302,6 +302,12 @@ class communicationView extends communication $editor = $editor . "\n" . '' . "\n"; Context::set('editor', $editor); $this->setTemplateFile('send_message'); + + // Fix for skins that don't support window_type=self + if(Context::get('window_type') === 'self') + { + Context::loadFile([$this->module_path . 'tpl/js/window_type.js', 'body']); + } } /** @@ -438,6 +444,12 @@ class communicationView extends communication Context::set('friend_group_list', $friend_group_list); $this->setTemplateFile('add_friend'); + + // Fix for skins that don't support window_type=self + if(Context::get('window_type') === 'self') + { + Context::loadFile([$this->module_path . 'tpl/js/window_type.js', 'body']); + } } /** @@ -495,6 +507,12 @@ class communicationView extends communication } $this->setTemplateFile('add_friend_group'); + + // Fix for skins that don't support window_type=self + if(Context::get('window_type') === 'self') + { + Context::loadFile([$this->module_path . 'tpl/js/window_type.js', 'body']); + } } } /* End of file communication.view.php */ diff --git a/modules/communication/tpl/js/window_type.js b/modules/communication/tpl/js/window_type.js new file mode 100644 index 000000000..364a46855 --- /dev/null +++ b/modules/communication/tpl/js/window_type.js @@ -0,0 +1,22 @@ +'use strict'; + +(function($) { + $(function() { + + // Find forms that submit to the Communication module. + const regexp = /^procCommunication(SendMessage|AddFriend(Group?))$/; + const forms = $('form').filter(function() { + return String($(this).find('input[name=act]').val()).match(regexp); + }); + + // Add window_type=self to each form. + forms.each(function() { + if ($(this).find('input[name=window_type]').length) { + return; + } + const hiddenInput = $('') + hiddenInput.insertAfter($(this).find('input[name=act]')); + }); + + }); +})(jQuery);