aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rwxr-xr-xapp/Resources/static/themes/material/index.js26
-rw-r--r--app/config/config.yml1
-rw-r--r--src/Wallabag/CoreBundle/Controller/EntryController.php8
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entry.html.twig9
4 files changed, 39 insertions, 5 deletions
diff --git a/app/Resources/static/themes/material/index.js b/app/Resources/static/themes/material/index.js
index d8f5628c..185ac1e0 100755
--- a/app/Resources/static/themes/material/index.js
+++ b/app/Resources/static/themes/material/index.js
@@ -120,4 +120,30 @@ $(document).ready(() => {
120 }); 120 });
121 }); 121 });
122 } 122 }
123
124 $('.markasread').on('click', () => {
125 const article = document.getElementById('article');
126 const link = document.getElementById('link-archive');
127 const articleId = article.dataset.id;
128 const xhr = new XMLHttpRequest();
129
130 xhr.onload = function toggleArchive() {
131 if (xhr.status === 200) {
132 const previousStatus = document.getElementById('archive-icon').innerHTML;
133 let status = link.dataset.iconUnread;
134 let label = link.dataset.labelUnread;
135 if (previousStatus === 'unarchive') {
136 status = link.dataset.iconRead;
137 label = link.dataset.labelRead;
138 }
139 document.getElementById('archive-icon').innerHTML = status;
140 document.getElementById('archive-label').innerHTML = label;
141 window.Materialize.toast(xhr.responseText, 4000);
142 }
143 };
144
145 const url = `${Routing.generate('archive_entry', { id: articleId })}?some_var_name=true`;
146 xhr.open('GET', url, false);
147 xhr.send(null);
148 });
123}); 149});
diff --git a/app/config/config.yml b/app/config/config.yml
index 4eea0531..f87835cf 100644
--- a/app/config/config.yml
+++ b/app/config/config.yml
@@ -373,6 +373,7 @@ fos_js_routing:
373 - howto 373 - howto
374 - fos_user_security_logout 374 - fos_user_security_logout
375 - new 375 - new
376 - archive_entry
376 377
377jms_serializer: 378jms_serializer:
378 handlers: 379 handlers:
diff --git a/src/Wallabag/CoreBundle/Controller/EntryController.php b/src/Wallabag/CoreBundle/Controller/EntryController.php
index 9b2954e7..5fc6fc55 100644
--- a/src/Wallabag/CoreBundle/Controller/EntryController.php
+++ b/src/Wallabag/CoreBundle/Controller/EntryController.php
@@ -7,6 +7,7 @@ use Pagerfanta\Adapter\DoctrineORMAdapter;
7use Pagerfanta\Exception\OutOfRangeCurrentPageException; 7use Pagerfanta\Exception\OutOfRangeCurrentPageException;
8use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache; 8use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;
9use Symfony\Bundle\FrameworkBundle\Controller\Controller; 9use Symfony\Bundle\FrameworkBundle\Controller\Controller;
10use Symfony\Component\HttpFoundation\JsonResponse;
10use Symfony\Component\HttpFoundation\Request; 11use Symfony\Component\HttpFoundation\Request;
11use Symfony\Component\Routing\Annotation\Route; 12use Symfony\Component\Routing\Annotation\Route;
12use Symfony\Component\Routing\Generator\UrlGeneratorInterface; 13use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
@@ -371,6 +372,11 @@ class EntryController extends Controller
371 $message = 'flashes.entry.notice.entry_archived'; 372 $message = 'flashes.entry.notice.entry_archived';
372 } 373 }
373 374
375 if ($request->query->get('some_var_name')) {
376
377 return new JsonResponse($this->get('translator')->trans($message));
378 }
379
374 $this->get('session')->getFlashBag()->add( 380 $this->get('session')->getFlashBag()->add(
375 'notice', 381 'notice',
376 $message 382 $message
@@ -381,6 +387,8 @@ class EntryController extends Controller
381 return $this->redirect($redirectUrl); 387 return $this->redirect($redirectUrl);
382 } 388 }
383 389
390
391
384 /** 392 /**
385 * Changes starred status for an entry. 393 * Changes starred status for an entry.
386 * 394 *
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entry.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entry.html.twig
index 527b1afc..899a8a7f 100644
--- a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entry.html.twig
+++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entry.html.twig
@@ -67,9 +67,9 @@
67 {% endif %} 67 {% endif %}
68 68
69 <li class="bold hide-on-med-and-down"> 69 <li class="bold hide-on-med-and-down">
70 <a class="waves-effect collapsible-header markasread" title="{{ markAsReadLabel|trans }}" href="{{ path('archive_entry', { 'id': entry.id }) }}" id="markAsRead"> 70 <a class="waves-effect collapsible-header markasread" title="{{ markAsReadLabel|trans }}" href="#" data-icon-read="done" data-icon-unread="unarchive" data-label-read="{{ 'entry.view.left_menu.set_as_read'|trans }}" data-label-unread="{{ 'entry.view.left_menu.set_as_unread'|trans }}" id="link-archive">
71 <i class="material-icons small">{% if entry.isArchived == 0 %}done{% else %}unarchive{% endif %}</i> 71 <i class="material-icons small" id="archive-icon">{% if entry.isArchived == 0 %}done{% else %}unarchive{% endif %}</i>
72 <span>{{ markAsReadLabel|trans }}</span> 72 <span id="archive-label">{{ markAsReadLabel|trans }}</span>
73 </a> 73 </a>
74 <div class="collapsible-body"></div> 74 <div class="collapsible-body"></div>
75 </li> 75 </li>
@@ -221,7 +221,7 @@
221{% endblock %} 221{% endblock %}
222 222
223{% block content %} 223{% block content %}
224 <div id="article"> 224 <div id="article" data-id="{{ entry.id }}">
225 <header class="mbm"> 225 <header class="mbm">
226 <h1><span{% if entry.language is defined and entry.language is not null %} lang="{{ entry.getHTMLLanguage() }}"{% endif %}>{{ entry.title|striptags|default('entry.default_title'|trans)|raw }}</span> <a href="{{ path('edit', { 'id': entry.id }) }}" title="{{ 'entry.view.edit_title'|trans }}"><i class="material-icons grey-text">create</i></a></h1> 226 <h1><span{% if entry.language is defined and entry.language is not null %} lang="{{ entry.getHTMLLanguage() }}"{% endif %}>{{ entry.title|striptags|default('entry.default_title'|trans)|raw }}</span> <a href="{{ path('edit', { 'id': entry.id }) }}" title="{{ 'entry.view.edit_title'|trans }}"><i class="material-icons grey-text">create</i></a></h1>
227 </header> 227 </header>
@@ -291,7 +291,6 @@
291 </ul> 291 </ul>
292 </div> 292 </div>
293 </div> 293 </div>
294
295<script id="annotationroutes" type="application/json"> 294<script id="annotationroutes" type="application/json">
296{ 295{
297 "prefix": "", 296 "prefix": "",