1
0
Fork 0

[frio] Add compose page JS trigger and theme setting

This commit is contained in:
Hypolite Petovan 2019-07-14 21:58:21 -04:00
parent ee52eb575e
commit d5efca1171
6 changed files with 38 additions and 5 deletions

View 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)) {

View file

@ -1313,7 +1313,8 @@ section ul.tabs {
section #jotOpen {
display: none;
}
#jotOpen {
#jotOpen,
#composeOpen {
margin-top: 3px;
float: right;
}

View 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

View 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">

View file

@ -183,6 +183,10 @@
});
</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>

View 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()