From d5efca1171d6d95298f832a37be53ef18868316e Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 14 Jul 2019 21:58:21 -0400 Subject: [PATCH] [frio] Add compose page JS trigger and theme setting --- view/theme/frio/config.php | 5 +++++ view/theme/frio/css/style.css | 3 ++- view/theme/frio/js/theme.js | 21 +++++++++++++++++--- view/theme/frio/templates/jot.tpl | 2 +- view/theme/frio/templates/theme_settings.tpl | 4 ++++ view/theme/frio/theme.php | 8 ++++++++ 6 files changed, 38 insertions(+), 5 deletions(-) diff --git a/view/theme/frio/config.php b/view/theme/frio/config.php index e6595d84e..df0f65a6b 100644 --- a/view/theme/frio/config.php +++ b/view/theme/frio/config.php @@ -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 the new Compose page.')], ]; if (array_key_exists('login_bg_image', $arr) && !array_key_exists('login_bg_image', $disable)) { diff --git a/view/theme/frio/css/style.css b/view/theme/frio/css/style.css index 30268701a..c986b7232 100644 --- a/view/theme/frio/css/style.css +++ b/view/theme/frio/css/style.css @@ -1313,7 +1313,8 @@ section ul.tabs { section #jotOpen { display: none; } -#jotOpen { +#jotOpen, +#composeOpen { margin-top: 3px; float: right; } diff --git a/view/theme/frio/js/theme.js b/view/theme/frio/js/theme.js index 19b5c4fa6..44a24b30a 100644 --- a/view/theme/frio/js/theme.js +++ b/view/theme/frio/js/theme.js @@ -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 diff --git a/view/theme/frio/templates/jot.tpl b/view/theme/frio/templates/jot.tpl index d5ba1bcc4..8b103eba5 100644 --- a/view/theme/frio/templates/jot.tpl +++ b/view/theme/frio/templates/jot.tpl @@ -1,6 +1,6 @@ {{* 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 3ac6282ca..9c32558b8 100644 --- a/view/theme/frio/templates/theme_settings.tpl +++ b/view/theme/frio/templates/theme_settings.tpl @@ -183,6 +183,10 @@ }); +
+ {{include file="field_checkbox.tpl" field=$enable_compose}} +
+
diff --git a/view/theme/frio/theme.php b/view/theme/frio/theme.php index a209664b9..5995f5437 100644 --- a/view/theme/frio/theme.php +++ b/view/theme/frio/theme.php @@ -41,6 +41,14 @@ function frio_init(App $a) 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 + +HTML; } function frio_install()