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
This commit is contained in:
Hypolite Petovan 2022-10-16 11:49:27 -04:00
parent d826fe0a3b
commit e556dc3c31
7 changed files with 29 additions and 7 deletions

View file

@ -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),
]);

View file

@ -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 <a href="/settings/display">Theme Customization settings</a>.'),
],
'$id' => 0,

View file

@ -1,5 +1,8 @@
<div class="generic-page-wrapper">
<h2>{{$l10n.compose_title}}</h2>
{{if $l10n.always_open_compose}}
<p>{{$l10n.always_open_compose nofilter}}</p>
{{/if}}
<div id="profile-jot-wrapper">
<form class="comment-edit-form" data-item-id="{{$id}}" id="comment-edit-form-{{$id}}" action="compose/{{$type}}" method="post">
{{*<!--<input type="hidden" name="return" value="{{$return_path}}" />-->*}}

View file

@ -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 <a href="/compose">Compose page</a> 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)) {

View file

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

View file

@ -1,5 +1,5 @@
{{* The button to open the jot - in This theme we move the button with js to the second nav bar *}}
<a class="btn btn-sm btn-primary pull-right" id="jotOpen" href="compose/{{$posttype}}{{if $content}}?body={{$content}}{{/if}}" aria-label="{{$new_post}}" title="{{$new_post}}"><i class="fa fa-pencil-square-o fa-2x"></i></a>
<a class="btn btn-sm btn-primary pull-right{{if !$always_open_compose}} modal-open{{/if}}" id="jotOpen" href="compose/{{$posttype}}{{if $content}}?body={{$content}}{{/if}}" aria-label="{{$new_post}}" title="{{$new_post}}"><i class="fa fa-pencil-square-o fa-2x"></i></a>
<div id="jot-content">
<div id="jot-sections">

View file

@ -209,6 +209,8 @@
});
</script>
{{include file="field_checkbox.tpl" field=$always_open_compose}}
<div class="settings-submit-wrapper pull-right">
<button type="submit" value="{{$submit}}" class="settings-submit btn btn-primary" name="frio-settings-submit">{{$submit}}</button>
</div>