Skip to content

Commit

Permalink
Remove <a href=""> in wiki\show.twig and wiki\category.twig
Browse files Browse the repository at this point in the history
  • Loading branch information
danon committed Jan 28, 2024
1 parent 25afb4e commit d9e31d5
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 30 deletions.
32 changes: 17 additions & 15 deletions resources/js/legacy/subscribe.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
$(() => {
'use strict';

$('.btn-subscribe').click((e) => {
let self = $(e.currentTarget);

$.post(self.attr('href'), () => {
self.toggleClass('on');
self.find('span').text(self.data(self.hasClass('on') ? 'off' : 'on'));
}).fail((e) => {
$('#modal-unauthorized').modal('show');
});

return false;
});
});
'use strict';
$('.btn-subscribe').click(event => {
const self = $(event.currentTarget);
if (!self.data('href')) {
return;
}
$
.post(self.data('href'), () => {
self.toggleClass('on');
self.find('span').text(self.data(self.hasClass('on') ? 'off' : 'on'));
})
.fail((e) => {
$('#modal-unauthorized').modal('show');
});
return false;
});
});
21 changes: 10 additions & 11 deletions resources/views/forum/topic.twig
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,10 @@
</template>

<vue-post-wrapper
v-for="post in posts"
:key="post.id"
:post="post"
@reply="reply"
v-for="post in posts"
:key="post.id"
:post="post"
@reply="reply"
></vue-post-wrapper>

<div class="row no-gutters mb-3">
Expand All @@ -148,10 +148,10 @@

{% if is_writeable %}
<vue-form
id="js-submit-form"
ref="js-submit-form"
:post="undefinedPost"
@save="resetPost"
id="js-submit-form"
ref="js-submit-form"
:post="undefinedPost"
@save="resetPost"
></vue-form>
{% endif %}

Expand All @@ -177,10 +177,9 @@
{% block side_menu %}
<div id="js-sidebar" class="box" v-cloak>
<ul class="side-menu mt-2">
<li v-if="isAuthorized" :class="{'on': topic.is_subscribed}" class="btn-subscribe">
<a @click="subscribe(topic)" href="javascript:">
<li v-if="isAuthorized" :class="{'on': topic.is_subscribed}" class="btn-subscribe" @click="subscribe(topic)">
<a>
<i :class="{'fas': topic.is_subscribed, 'far': !topic.is_subscribed}" class="fa-star fa-fw"></i>

<span v-if="topic.is_subscribed">Zakończ obserwację</span>
<span v-else>Obserwuj wątek</span>
</a>
Expand Down
14 changes: 11 additions & 3 deletions resources/views/wiki/category.twig
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,18 @@
</a>
{% endif %}

<a class="nav-item" href="{{ route('wiki.submit') }}?parentId={{ wiki.id }}" title="Dodaj nową stronę w tej kategorii"><span>Napisz nowy artykuł w tym dziale</span></a>
<a class="nav-item" href="{{ route('wiki.subscribe', [wiki.id]) }}" class="btn-subscribe {{ subscribed ? 'on' }}" data-off="{{ labels[0] }}" data-on="{{ labels[1] }}"
<a class="nav-item"
href="{{ route('wiki.submit') }}?parentId={{ wiki.id }}"
title="Dodaj nową stronę w tej kategorii">
<span>Napisz nowy artykuł w tym dziale</span>
</a>

{% set labels = ['Usuń z ulubionych', 'Dodaj do ulubionych'] %}
<a class="nav-item btn-subscribe {{ subscribed ? 'on' }}"
data-href="{{ route('wiki.subscribe', [wiki.id]) }}"
data-off="{{ labels[0] }}"
data-on="{{ labels[1] }}"
title="Obserwując tę stronę będziesz otrzymywał powiadomienia o jej zmianach">
{% set labels = ['Usuń z ulubionych', 'Dodaj do ulubionych'] %}
<span>{{ labels[not subscribed] }}</span>
</a>

Expand Down
2 changes: 1 addition & 1 deletion resources/views/wiki/show.twig
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<li>
{% set labels = ['Usuń z ulubionych', 'Dodaj do ulubionych'] %}
<a class="btn-subscribe {{ subscribed ? 'on' }}"
href="{{ route('wiki.subscribe', [wiki.id]) }}"
data-href="{{ route('wiki.subscribe', [wiki.id]) }}"
data-off="{{ labels[0] }}"
data-on="{{ labels[1] }}"
title="Obserwując tę stronę będziesz otrzymywał powiadomienia o jej zmianach">
Expand Down

0 comments on commit d9e31d5

Please sign in to comment.