[frio] Add compose page JS trigger and theme setting
authorHypolite Petovan <hypolite@mrpetovan.com>
Mon, 15 Jul 2019 01:58:21 +0000 (21:58 -0400)
committerHypolite Petovan <hypolite@mrpetovan.com>
Tue, 30 Jul 2019 00:31:47 +0000 (20:31 -0400)
view/theme/frio/config.php
view/theme/frio/css/style.css
view/theme/frio/js/theme.js
view/theme/frio/templates/jot.tpl
view/theme/frio/templates/theme_settings.tpl
view/theme/frio/theme.php

index e6595d84e661025f2aa65d2382a37ea11f5bb240..df0f65a6b873e8cd4b301beea015c1e7d5d48333 100644 (file)
@@ -25,6 +25,7 @@ function theme_post(App $a)
                PConfig::set(local_user(), 'frio', 'background_image', $_POST['frio_background_image'] ?? '');
                PConfig::set(local_user(), 'frio', 'bg_image_option',  $_POST['frio_bg_image_option']  ?? '');
                PConfig::set(local_user(), 'frio', 'css_modified',     time());
+               PConfig::set(local_user(), 'frio', 'enable_compose',   $_POST['frio_enable_compose']   ?? 0);
        }
 }
 
@@ -46,6 +47,7 @@ function theme_admin_post(App $a)
                Config::set('frio', 'login_bg_image',   $_POST['frio_login_bg_image']   ?? '');
                Config::set('frio', 'login_bg_color',   $_POST['frio_login_bg_color']   ?? '');
                Config::set('frio', 'css_modified',     time());
+               Config::set('frio', 'enable_compose',   $_POST['frio_enable_compose']   ?? 0);
        }
 }
 
@@ -67,6 +69,7 @@ function theme_content(App $a)
        $arr['contentbg_transp'] = PConfig::get(local_user(), 'frio', 'contentbg_transp', Config::get('frio', 'contentbg_transp'));
        $arr['background_image'] = PConfig::get(local_user(), 'frio', 'background_image', Config::get('frio', 'background_image'));
        $arr['bg_image_option']  = PConfig::get(local_user(), 'frio', 'bg_image_option' , Config::get('frio', 'bg_image_option'));
+       $arr['enable_compose']   = PConfig::get(local_user(), 'frio', 'enable_compose'  , Config::get('frio', 'enable_compose'));
 
        return frio_form($arr);
 }
@@ -89,6 +92,7 @@ function theme_admin(App $a)
        $arr['bg_image_option']  = Config::get('frio', 'bg_image_option');
        $arr['login_bg_image']   = Config::get('frio', 'login_bg_image');
        $arr['login_bg_color']   = Config::get('frio', 'login_bg_color');
+       $arr['enable_compose']   = Config::get('frio', 'enable_compose');
 
        return frio_form($arr);
 }
@@ -132,6 +136,7 @@ function frio_form($arr)
                '$background_image' => array_key_exists('background_image', $disable) ? '' : ['frio_background_image', L10n::t('Set the background image'), $arr['background_image'], $background_image_help, false],
                '$bg_image_options_title' => L10n::t('Background image style'),
                '$bg_image_options' => Image::get_options($arr),
+               '$enable_compose'   => ['frio_enable_compose', L10n::t('Enable Compose page'), $arr['enable_compose'], L10n::t('This replaces the jot modal window for writing new posts with a link to <a href="compose">the new Compose page</a>.')],
        ];
 
        if (array_key_exists('login_bg_image', $arr) && !array_key_exists('login_bg_image', $disable)) {
index 30268701a0f0901fd30f115e0892b604479fa12a..c986b7232c9d3847ebe677ab16a83e9324d41629 100644 (file)
@@ -1313,7 +1313,8 @@ section ul.tabs {
 section #jotOpen {
     display: none;
 }
-#jotOpen {
+#jotOpen,
+#composeOpen {
     margin-top: 3px;
     float: right;
 }
index 19b5c4fa6e72a70e9c9216c884202580ecbc56bc..44a24b30a11884e1cfae92537a5247922d5a6012 100644 (file)
@@ -64,9 +64,24 @@ $(document).ready(function(){
        });
 
        // add Jot botton to the scecond navbar
-       if( $("section #jotOpen").length ) {
-               $("section #jotOpen").appendTo("#topbar-second > .container > #navbar-button");
-               if( $("#jot-popup").is(":hidden")) $("#topbar-second > .container > #navbar-button #jotOpen").hide();
+       let $jotButton = $("#jotOpen");
+       let $composeButton = $("#composeOpen");
+       if (compose) {
+               $jotButton.hide();
+               if ($composeButton.length) {
+                       $composeButton.appendTo("#topbar-second > .container > #navbar-button");
+                       if($("#jot-popup").is(":hidden")) {
+                               $composeButton.hide();
+                       }
+               }
+       } else {
+               $composeButton.hide();
+               if ($jotButton.length) {
+                       $jotButton.appendTo("#topbar-second > .container > #navbar-button");
+                       if($("#jot-popup").is(":hidden")) {
+                               $jotButton.hide();
+                       }
+               }
        }
 
        // show bulk deletion button at network page if checkbox is checked
index d5ba1bcc458e4f503947fc2548f194e57e750e13..8b103eba562aa7875c747de44a696801ea3015a3 100644 (file)
@@ -1,6 +1,6 @@
 {{* The button to open the jot - in This theme we move the button with js to the second nav bar *}}
 <button class="btn btn-sm btn-main pull-right" id="jotOpen" aria-label="{{$new_post}}" title="{{$new_post}}" onclick="jotShow();"><i class="fa fa-pencil-square-o fa-2x"></i></button>
-
+<a class="btn btn-sm btn-main pull-right" id="composeOpen" 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 3ac6282cabc3f02df46f76fe305a6ea66c3b7122..9c32558b8ebde183722d47c0c2c9312c3859da86 100644 (file)
        });
 </script>
 
+<div class="form-group">
+    {{include file="field_checkbox.tpl" field=$enable_compose}}
+</div>
+
 <div class="settings-submit-wrapper form-group pull-right">
        <button type="submit" value="{{$submit}}" class="settings-submit btn btn-primary" name="frio-settings-submit">{{$submit}}</button>
 </div>
index a209664b9388e89c21fd4543ca61de084e848e60..5995f54374171f4b2e701e31a8b96f182f22f621 100644 (file)
@@ -41,6 +41,14 @@ function frio_init(App $a)
                        </script>
 EOT;
        }
+
+       $enable_compose = \Friendica\Core\PConfig::get(local_user(), 'frio', 'enable_compose');
+       $compose = $enable_compose === '1' || $enable_compose === null && Config::get('frio', 'enable_compose') ? 1 : 0;
+       $a->page['htmlhead'] .= <<< HTML
+               <script type="text/javascript">
+                       var compose = $compose;
+               </script>
+HTML;
 }
 
 function frio_install()