diff options
| author | 2013-04-13 15:27:36 +0200 | |
|---|---|---|
| committer | 2013-04-13 15:27:36 +0200 | |
| commit | 9b9543109e36a5409fe71eb084cfac680dfc7cbd (patch) | |
| tree | 0876746883cd90d5f1e9a63e208342699e427690 | |
| parent | a4beb7b772fdc3c8c894b93611bfb030c9456f07 (diff) | |
Fix issue #39 : actualisation de tous les flux grâce à Ajax
| -rwxr-xr-x | app/controllers/feedController.php | 8 | ||||
| -rwxr-xr-x | app/controllers/indexController.php | 1 | ||||
| -rwxr-xr-x | app/controllers/javascriptController.php | 9 | ||||
| -rw-r--r-- | app/layout/nav_menu.phtml | 2 | ||||
| -rw-r--r-- | app/views/javascript/actualize.phtml | 46 | ||||
| -rw-r--r-- | public/theme/freshrss.css | 20 |
6 files changed, 80 insertions, 6 deletions
diff --git a/app/controllers/feedController.php b/app/controllers/feedController.php index d2a2184eb..83fc19e20 100755 --- a/app/controllers/feedController.php +++ b/app/controllers/feedController.php @@ -156,9 +156,13 @@ class feedController extends ActionController { 'content' => 'Aucun flux n\'a pu être mis à jour' ); } - Session::_param ('notification', $notif); - Request::forward (array (), true); + if (Request::param ('ajax', 0) == 0) { + Session::_param ('notification', $notif); + Request::forward (array (), true); + } else { + $this->view->_useLayout (false); + } } public function massiveImportAction () { diff --git a/app/controllers/indexController.php b/app/controllers/indexController.php index a11c26044..8fa911631 100755 --- a/app/controllers/indexController.php +++ b/app/controllers/indexController.php @@ -8,6 +8,7 @@ class indexController extends ActionController { public function indexAction () { View::appendScript (Url::display ('/scripts/shortcut.js')); View::appendScript (Url::display (array ('c' => 'javascript', 'a' => 'main'))); + View::appendScript (Url::display (array ('c' => 'javascript', 'a' => 'actualize'))); $entryDAO = new EntryDAO (); $feedDAO = new FeedDAO (); diff --git a/app/controllers/javascriptController.php b/app/controllers/javascriptController.php index 8060f560c..071cf65a4 100755 --- a/app/controllers/javascriptController.php +++ b/app/controllers/javascriptController.php @@ -5,8 +5,11 @@ class javascriptController extends ActionController { $this->view->_useLayout (false); header('Content-type: text/javascript'); } - - public function mainAction () { - + + public function mainAction () {} + + public function actualizeAction () { + $feedDAO = new FeedDAO (); + $this->view->feeds = $feedDAO->listFeeds (); } } diff --git a/app/layout/nav_menu.phtml b/app/layout/nav_menu.phtml index 90fe4aea1..5d7dd3091 100644 --- a/app/layout/nav_menu.phtml +++ b/app/layout/nav_menu.phtml @@ -1,7 +1,7 @@ <div class="nav_menu"> <a class="btn toggle_aside" href="#aside_flux"><i class="icon i_category"></i></a> - <a class="btn" href="<?php echo _url ('feed', 'actualize'); ?>"><i class="icon i_refresh"></i></a> + <a id="actualize" class="btn" href="<?php echo _url ('feed', 'actualize'); ?>"><i class="icon i_refresh"></i></a> <?php $get = false; diff --git a/app/views/javascript/actualize.phtml b/app/views/javascript/actualize.phtml new file mode 100644 index 000000000..ad1c4e2e6 --- /dev/null +++ b/app/views/javascript/actualize.phtml @@ -0,0 +1,46 @@ +var feeds = new Array (); +<?php foreach ($this->feeds as $feed) { ?> +feeds.push ("<?php echo Url::display (array ('c' => 'feed', 'a' => 'actualize', 'params' => array ('id' => $feed->id (), 'ajax' => '1')), 'php'); ?>"); +<?php } ?> + +function initProgressBar (init) { + if (init) { + $("body").after ("\<div id=\"actualizeProgress\" class=\"actualizeProgress\">\ + Actualisation :\ + <progress id=\"actualizeProgressBar\" value=\"0\" max=\"" + feeds.length + "\"></progress>\ + <span class=\"progress\">0 / " + feeds.length + "</span>\ + </div>"); + } else { + window.location.reload (); + } +} +function updateProgressBar (i) { + $("#actualizeProgressBar").val(i); + $("#actualizeProgress .progress").html (i + " / " + feeds.length); +} + +function updateFeeds () { + initProgressBar (true); + + var i = 0; + for (var f in feeds) { + $.ajax ({ + type: 'POST', + url: feeds[f], + }).done (function (data) { + i++; + updateProgressBar (i); + + if (i == feeds.length) { + initProgressBar (false); + } + }); + } +} + +$(document).ready (function () { + $("#actualize").click (function () { + updateFeeds (); + return false; + }); +}); diff --git a/public/theme/freshrss.css b/public/theme/freshrss.css index 6db467a76..f64770b81 100644 --- a/public/theme/freshrss.css +++ b/public/theme/freshrss.css @@ -381,6 +381,26 @@ display: none; } +.actualizeProgress { + position: fixed; + top: 0; left: 33%; right: 33%; + width: 33%; + padding: 5px; + background: #fff; + text-align: center; + border: 1px solid #ddd; + border-top: none; + border-radius: 0 0 5px 5px; +} + .actualizeProgress progress { + vertical-align: middle; + } + .actualizeProgress .progress { + color: #999; + font-size: 90%; + vertical-align: middle; + } + @media(max-width: 840px) { .header, .aside .btn-important, |
