From e556dc3c31101d880d9bc7a1188bb107fe57a246 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 16 Oct 2022 11:49:27 -0400 Subject: [PATCH] Add new frio.always_open_compose setting - This setting allows the New Post button to always open the Compose page instead of the modal by default --- src/Content/Conversation.php | 3 ++- src/Module/Item/Compose.php | 10 +++++++++- view/templates/item/compose.tpl | 3 +++ view/theme/frio/config.php | 6 ++++++ view/theme/frio/js/theme.js | 10 ++++++---- view/theme/frio/templates/jot.tpl | 2 +- view/theme/frio/templates/theme_settings.tpl | 2 ++ 7 files changed, 29 insertions(+), 7 deletions(-) diff --git a/src/Content/Conversation.php b/src/Content/Conversation.php index 237d192fdc..84f75cff32 100644 --- a/src/Content/Conversation.php +++ b/src/Content/Conversation.php @@ -393,7 +393,8 @@ class Conversation '$message' => $this->l10n->t('Message'), '$browser' => $this->l10n->t('Browser'), - '$compose_link_title' => $this->l10n->t('Open Compose page'), + '$compose_link_title' => $this->l10n->t('Open Compose page'), + '$always_open_compose' => $this->pConfig->get(local_user(), 'frio', 'always_open_compose', false), ]); diff --git a/src/Module/Item/Compose.php b/src/Module/Item/Compose.php index 895a548e40..bd531d484b 100644 --- a/src/Module/Item/Compose.php +++ b/src/Module/Item/Compose.php @@ -26,6 +26,7 @@ use Friendica\App; use Friendica\BaseModule; use Friendica\Content\Feature; use Friendica\Core\ACL; +use Friendica\Core\Config\Capability\IManageConfigValues; use Friendica\Core\Hook; use Friendica\Core\L10n; use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues; @@ -60,7 +61,10 @@ class Compose extends BaseModule /** @var IManagePersonalConfigValues */ private $pConfig; - public function __construct(IManagePersonalConfigValues $pConfig, App\Page $page, ACLFormatter $ACLFormatter, SystemMessages $systemMessages, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = []) + /** @var IManageConfigValues */ + private $config; + + public function __construct(IManageConfigValues $config, IManagePersonalConfigValues $pConfig, App\Page $page, ACLFormatter $ACLFormatter, SystemMessages $systemMessages, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = []) { parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); @@ -68,6 +72,7 @@ class Compose extends BaseModule $this->ACLFormatter = $ACLFormatter; $this->page = $page; $this->pConfig = $pConfig; + $this->config = $config; } protected function post(array $request = []) @@ -199,6 +204,9 @@ class Compose extends BaseModule 'wait' => $this->l10n->t('Please wait'), 'placeholdertitle' => $this->l10n->t('Set title'), 'placeholdercategory' => Feature::isEnabled(local_user(),'categories') ? $this->l10n->t('Categories (comma-separated list)') : '', + 'always_open_compose' => $this->pConfig->get(local_user(), 'frio', 'always_open_compose', + $this->config->get('frio', 'always_open_compose', false)) ? '' : + $this->l10n->t('You can make this page always open when you use the New Post button in the Theme Customization settings.'), ], '$id' => 0, diff --git a/view/templates/item/compose.tpl b/view/templates/item/compose.tpl index a01ea95a0b..5583650e04 100644 --- a/view/templates/item/compose.tpl +++ b/view/templates/item/compose.tpl @@ -1,5 +1,8 @@

{{$l10n.compose_title}}

+ {{if $l10n.always_open_compose}} +

{{$l10n.always_open_compose nofilter}}

+ {{/if}}
{{**}} diff --git a/view/theme/frio/config.php b/view/theme/frio/config.php index 1ee67db3d8..2dcf002048 100644 --- a/view/theme/frio/config.php +++ b/view/theme/frio/config.php @@ -44,6 +44,7 @@ function theme_post(App $a) 'bg_image_option', 'login_bg_image', 'login_bg_color', + 'always_open_compose', ] as $field) { if (isset($_POST['frio_' . $field])) { DI::pConfig()->set(local_user(), 'frio', $field, $_POST['frio_' . $field]); @@ -74,6 +75,7 @@ function theme_admin_post(App $a) 'bg_image_option', 'login_bg_image', 'login_bg_color', + 'always_open_compose', ] as $field) { if (isset($_POST['frio_' . $field])) { DI::config()->set('frio', $field, $_POST['frio_' . $field]); @@ -108,6 +110,7 @@ function theme_content(): string 'contentbg_transp' => DI::pConfig()->get(local_user(), 'frio', 'contentbg_transp' , DI::config()->get('frio', 'contentbg_transp')), 'background_image' => DI::pConfig()->get(local_user(), 'frio', 'background_image' , DI::config()->get('frio', 'background_image')), 'bg_image_option' => DI::pConfig()->get(local_user(), 'frio', 'bg_image_option' , DI::config()->get('frio', 'bg_image_option')), + 'always_open_compose' => DI::pConfig()->get(local_user(), 'frio', 'always_open_compose', DI::config()->get('frio', 'always_open_compose', false)), ]; return frio_form($arr); @@ -132,6 +135,7 @@ function theme_admin(): string 'bg_image_option' => DI::config()->get('frio', 'bg_image_option'), 'login_bg_image' => DI::config()->get('frio', 'login_bg_image'), 'login_bg_color' => DI::config()->get('frio', 'login_bg_color'), + 'always_open_compose' => DI::config()->get('frio', 'always_open_compose', false), ]; return frio_form($arr); @@ -180,6 +184,8 @@ function frio_form($arr) '$background_image' => array_key_exists('background_image', $disable) ? '' : ['frio_background_image', DI::l10n()->t('Set the background image'), $arr['background_image'], $background_image_help, false], '$bg_image_options_title' => DI::l10n()->t('Background image style'), '$bg_image_options' => Image::get_options($arr), + + '$always_open_compose' => ['frio_always_open_compose', DI::l10n()->t('Always open Compose page'), $arr['always_open_compose'], DI::l10n()->t('The New Post button always open the Compose page instead of the modal form. When this is disabled, the Compose page can be accessed with a middle click on the link or from the modal.')], ]; if (array_key_exists('login_bg_image', $arr) && !array_key_exists('login_bg_image', $disable)) { diff --git a/view/theme/frio/js/theme.js b/view/theme/frio/js/theme.js index edd7282f79..60aa88ba58 100644 --- a/view/theme/frio/js/theme.js +++ b/view/theme/frio/js/theme.js @@ -87,10 +87,12 @@ $(document).ready(function () { if ($("#jot-popup").is(":hidden")) { $jotButton.hide(); } - $jotButton.on("click", function (e) { - e.preventDefault(); - jotShow(); - }); + if ($jotButton.hasClass('modal-open')) { + $jotButton.on("click", function (e) { + e.preventDefault(); + jotShow(); + }); + } } let $body = $("body"); diff --git a/view/theme/frio/templates/jot.tpl b/view/theme/frio/templates/jot.tpl index 0f878d4c53..c38e8531c6 100644 --- a/view/theme/frio/templates/jot.tpl +++ b/view/theme/frio/templates/jot.tpl @@ -1,5 +1,5 @@ {{* The button to open the jot - in This theme we move the button with js to the second nav bar *}} - +
diff --git a/view/theme/frio/templates/theme_settings.tpl b/view/theme/frio/templates/theme_settings.tpl index 7dfc49719a..3c3c9cc2e2 100644 --- a/view/theme/frio/templates/theme_settings.tpl +++ b/view/theme/frio/templates/theme_settings.tpl @@ -209,6 +209,8 @@ }); +{{include file="field_checkbox.tpl" field=$always_open_compose}} +