]> git.mxchange.org Git - friendica.git/commitdiff
Add new frio.always_open_compose setting
authorHypolite Petovan <hypolite@mrpetovan.com>
Sun, 16 Oct 2022 15:49:27 +0000 (11:49 -0400)
committerHypolite Petovan <hypolite@mrpetovan.com>
Sun, 16 Oct 2022 15:49:27 +0000 (11:49 -0400)
- This setting allows the New Post button to always open the Compose page instead of the modal by default

src/Content/Conversation.php
src/Module/Item/Compose.php
view/templates/item/compose.tpl
view/theme/frio/config.php
view/theme/frio/js/theme.js
view/theme/frio/templates/jot.tpl
view/theme/frio/templates/theme_settings.tpl

index 237d192fdc4f8cc579ada5bdb6f9ae682777b591..84f75cff326e607767821af7c83423c2299e9402 100644 (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),
                ]);
 
 
index 895a548e40d70aada694acc289e6abdda3624dd3..bd531d484b596d8becb3055e48596fff20e0082f 100644 (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,
index a01ea95a0b8a6c3d06f358efd3c0704ce1f1d0ed..5583650e048c222b2470bc2fab2c6d159c2c39ae 100644 (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}}" />-->*}}
index 1ee67db3d80e5f0bd7e4daf35030f12bb2b70e6f..2dcf0020487a6f323e0ee833a8cba408ae861c60 100644 (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)) {
index edd7282f792e06bc5bae83e76f77292aceac3ea5..60aa88ba581bd23c73f20a496a19766c42303012 100644 (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");
index 0f878d4c53b6e2b2cecb7c05ce22c19703d8590d..c38e8531c6e7feeb2a4397404c7e640d676aba75 100644 (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">
index 7dfc49719ad17dff0eab77fb8348bce0048ef8d5..3c3c9cc2e209b79d388a9d9cad42d10f1dd9f058 100644 (file)
        });
 </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>