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);