Skip to content

Commit 6e55595

Browse files
committed
Light refactoring
1 parent 5358f83 commit 6e55595

File tree

4 files changed

+42
-69
lines changed

4 files changed

+42
-69
lines changed

app/views/helpers/index/normal/entry_bottom.phtml

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -76,39 +76,7 @@
7676
<a class="dropdown-toggle" href="#dropdown-share-<?= $this->entry->id() ?>">
7777
<?= _i('share') ?><?= _t('index.share') ?>
7878
</a>
79-
80-
<ul class="dropdown-menu">
81-
<li class="dropdown-header"><?= _t('index.share') ?> <a href="<?= _url('configure', 'integration') ?>"><?= _i('configure') ?></a></li><?php
82-
$id = $this->entry->id();
83-
$link = $this->entry->link();
84-
$title = $this->entry->title() . ' · ' . ($this->feed === null ? '' : $this->feed->name());
85-
foreach (FreshRSS_Context::userConf()->sharing as $share_options) {
86-
$share = FreshRSS_Share::get($share_options['type']);
87-
if ($share === null) {
88-
continue;
89-
}
90-
$cssClass = $share->isDeprecated() ? ' error' : '';
91-
$share_options['id'] = $id;
92-
$share_options['link'] = $link;
93-
$share_options['title'] = $title;
94-
$share->update($share_options);
95-
?><li class="item share<?= $cssClass ?>">
96-
<?php if ('GET' === $share->method()) {
97-
if ($share->HTMLtag() !== 'button') {?>
98-
<a target="_blank" rel="noreferrer" href="<?= $share->url() ?>" data-type="<?= $share->type() ?>"><?= $share->name() ?></a>
99-
<?php } else { ?>
100-
<button type="button" class="as-link" data-url="<?= $share->url() ?>" data-type="<?= $share->type() ?>" data-title="<?= htmlspecialchars($title) ?>"><?= $share->name() ?></button>
101-
<?php
102-
}
103-
} else {?>
104-
<a href="POST"><?= $share->name() ?></a>
105-
<form method="POST" action="<?= $share->url() ?>" disabled="disabled">
106-
<input type="hidden" value="<?= $link ?>" name="<?= $share->field() ?>"/>
107-
</form>
108-
<?php } ?>
109-
</li><?php
110-
}
111-
?></ul>
79+
<?php $this->renderHelper('index/normal/entry_share_menu'); ?>
11280
<a class="dropdown-close" href="#close">❌</a>
11381
</div>
11482
<?php } ?>

app/views/helpers/index/normal/entry_header.phtml

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -80,39 +80,7 @@
8080
<a class="dropdown-toggle" href="#dropdown-share2-<?= $this->entry->id() ?>" title="<?= _t('index.share') ?>">
8181
<?= _i('share') ?>
8282
</a>
83-
84-
<ul class="dropdown-menu">
85-
<li class="dropdown-header"><?= _t('index.share') ?> <a href="<?= _url('configure', 'integration') ?>"><?= _i('configure') ?></a></li><?php
86-
$id = $this->entry->id();
87-
$link = $this->entry->link();
88-
$title = $this->entry->title() . ' · ' . ($this->feed === null ? '' : $this->feed->name());
89-
foreach (FreshRSS_Context::userConf()->sharing as $share_options) {
90-
$share = FreshRSS_Share::get($share_options['type']);
91-
if ($share === null) {
92-
continue;
93-
}
94-
$cssClass = $share->isDeprecated() ? ' error' : '';
95-
$share_options['id'] = $id;
96-
$share_options['link'] = $link;
97-
$share_options['title'] = $title;
98-
$share->update($share_options);
99-
?><li class="item share<?= $cssClass ?>">
100-
<?php if ('GET' === $share->method()) {
101-
if ($share->HTMLtag() !== 'button') {?>
102-
<a target="_blank" rel="noreferrer" href="<?= $share->url() ?>" data-type="<?= $share->type() ?>"><?= $share->name() ?></a>
103-
<?php } else { ?>
104-
<button type="button" class="as-link" data-url="<?= $share->url() ?>" data-type="<?= $share->type() ?>" data-title="<?= htmlspecialchars($title) ?>"><?= $share->name() ?></button>
105-
<?php
106-
}
107-
} else {?>
108-
<a href="POST"><?= $share->name() ?></a>
109-
<form method="POST" action="<?= $share->url() ?>" disabled="disabled">
110-
<input type="hidden" value="<?= $link ?>" name="<?= $share->field() ?>"/>
111-
</form>
112-
<?php } ?>
113-
</li><?php
114-
}
115-
?></ul>
83+
<?php $this->renderHelper('index/normal/entry_share_menu'); ?>
11684
<a class="dropdown-close" href="#close">❌</a>
11785
</div>
11886
</li>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
declare(strict_types=1);
3+
/** @var FreshRSS_View $this */
4+
//TODO: To reduce output size, replace by an on-demand JavaScript menu, potentially using HTML template element
5+
?>
6+
<ul class="dropdown-menu">
7+
<li class="dropdown-header"><?= _t('index.share') ?> <a href="<?= _url('configure', 'integration') ?>"><?= _i('configure') ?></a></li><?php
8+
$id = $this->entry->id();
9+
$link = $this->entry->link();
10+
$title = $this->entry->title() . ' · ' . ($this->feed === null ? '' : $this->feed->name());
11+
foreach (FreshRSS_Context::userConf()->sharing as $share_options) {
12+
$share = FreshRSS_Share::get($share_options['type']);
13+
if ($share === null) {
14+
continue;
15+
}
16+
$cssClass = $share->isDeprecated() ? ' error' : '';
17+
$share_options['id'] = $id;
18+
$share_options['link'] = $link;
19+
$share_options['title'] = $title;
20+
$share->update($share_options);
21+
?><li class="item share<?= $cssClass ?>">
22+
<?php if ('GET' === $share->method()) {
23+
if ($share->HTMLtag() !== 'button') {?>
24+
<a target="_blank" rel="noreferrer" href="<?= $share->url() ?>" data-type="<?= $share->type() ?>"><?= $share->name() ?></a>
25+
<?php } else { ?>
26+
<button type="button" class="as-link" data-url="<?= $share->url() ?>" data-type="<?= $share->type() ?>" data-title="<?= htmlspecialchars($title) ?>"><?= $share->name() ?></button>
27+
<?php
28+
}
29+
} else {?>
30+
<a href="POST"><?= $share->name() ?></a>
31+
<form method="POST" action="<?= $share->url() ?>" disabled="disabled">
32+
<input type="hidden" value="<?= $link ?>" name="<?= $share->field() ?>"/>
33+
</form>
34+
<?php } ?>
35+
</li><?php
36+
}
37+
?></ul>

p/scripts/main.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ function mark_favorite(div) {
402402
const freshrssOpenArticleEvent = document.createEvent('Event');
403403
freshrssOpenArticleEvent.initEvent('freshrss:openArticle', true, true);
404404

405-
function load_allLazyImages(rootElement) {
405+
function loadLazyImages(rootElement) {
406406
rootElement.querySelectorAll('img[data-original], iframe[data-original]').forEach(function (el) {
407407
el.src = el.getAttribute('data-original');
408408
el.removeAttribute('data-original');
@@ -416,7 +416,7 @@ function toggleContent(new_active, old_active, skipping) {
416416
}
417417

418418
if (context.does_lazyload && !skipping) {
419-
load_allLazyImages(new_active);
419+
loadLazyImages(new_active);
420420
}
421421

422422
if (old_active !== new_active) {
@@ -1113,7 +1113,7 @@ function init_stream(stream) {
11131113
if (content_el === null) {
11141114
content_el = el.closest('.flux').querySelector('.flux_content .content');
11151115
}
1116-
load_allLazyImages(content_el);
1116+
loadLazyImages(content_el);
11171117
tmp_window.document.writeln(content_el.innerHTML);
11181118
tmp_window.document.close();
11191119
tmp_window.focus();

0 commit comments

Comments
 (0)