diff options
| author | 2013-08-21 15:22:30 +0200 | |
|---|---|---|
| committer | 2013-08-21 15:22:30 +0200 | |
| commit | 456c95d2dbb40d358d79f426f68eb03f5f447945 (patch) | |
| tree | e3fe6053b120697e04dadb66269fd41cfa5e1d33 | |
| parent | 94a50086d8eb5d3336dff66b2f4efcc7bd3dfa71 (diff) | |
Fix issue #125 : "Load more" automatique
En bas de page, si l'option a été cochée (ne l'est pas par défaut), on
va charger automatiquement les articles suivants
| -rwxr-xr-x | app/controllers/configureController.php | 3 | ||||
| -rw-r--r-- | app/i18n/en.php | 1 | ||||
| -rw-r--r-- | app/i18n/fr.php | 1 | ||||
| -rwxr-xr-x | app/models/RSSConfiguration.php | 2 | ||||
| -rw-r--r-- | app/views/configure/display.phtml | 10 | ||||
| -rw-r--r-- | app/views/javascript/main.phtml | 11 | ||||
| -rw-r--r-- | public/scripts/endless_mode.js | 10 |
7 files changed, 34 insertions, 4 deletions
diff --git a/app/controllers/configureController.php b/app/controllers/configureController.php index 71ab45fbe..0fce9679f 100755 --- a/app/controllers/configureController.php +++ b/app/controllers/configureController.php @@ -144,6 +144,7 @@ class configureController extends ActionController { $nb = Request::param ('posts_per_page', 10); $mode = Request::param ('view_mode', 'normal'); $view = Request::param ('default_view', 'all'); + $auto_load_more = Request::param ('auto_load_more', 'no'); $display = Request::param ('display_posts', 'no'); $lazyload = Request::param ('lazyload', 'no'); $sort = Request::param ('sort_order', 'low_to_high'); @@ -160,6 +161,7 @@ class configureController extends ActionController { $this->view->conf->_postsPerPage (intval ($nb)); $this->view->conf->_viewMode ($mode); $this->view->conf->_defaultView ($view); + $this->view->conf->_autoLoadMore ($auto_load_more); $this->view->conf->_displayPosts ($display); $this->view->conf->_lazyload ($lazyload); $this->view->conf->_sortOrder ($sort); @@ -179,6 +181,7 @@ class configureController extends ActionController { 'posts_per_page' => $this->view->conf->postsPerPage (), 'view_mode' => $this->view->conf->viewMode (), 'default_view' => $this->view->conf->defaultView (), + 'auto_load_more' => $this->view->conf->autoLoadMore (), 'display_posts' => $this->view->conf->displayPosts (), 'lazyload' => $this->view->conf->lazyload (), 'sort_order' => $this->view->conf->sortOrder (), diff --git a/app/i18n/en.php b/app/i18n/en.php index 5bcc33be1..61bf57e4e 100644 --- a/app/i18n/en.php +++ b/app/i18n/en.php @@ -155,6 +155,7 @@ return array ( 'articles_per_page' => 'Number of articles per page', 'default_view' => 'Default view', 'sort_order' => 'Sort order', + 'auto_load_more' => 'Load next articles at the page bottom', 'display_articles_unfolded' => 'Show articles unfolded by default', 'img_with_lazyload' => 'Use "lazy load" mode to load pictures', 'auto_read_when' => 'Mark as read when', diff --git a/app/i18n/fr.php b/app/i18n/fr.php index 71b3703cb..0f14c0700 100644 --- a/app/i18n/fr.php +++ b/app/i18n/fr.php @@ -155,6 +155,7 @@ return array ( 'articles_per_page' => 'Nombre d\'articles par page', 'default_view' => 'Vue par défaut', 'sort_order' => 'Ordre de tri', + 'auto_load_more' => 'Charger les articles suivants en bas de page', 'display_articles_unfolded' => 'Afficher les articles dépliés par défaut', 'img_with_lazyload' => 'Utiliser le mode "lazy load" pour charger les images', 'auto_read_when' => 'Marquer comme lu lorsque', diff --git a/app/models/RSSConfiguration.php b/app/models/RSSConfiguration.php index b3df64307..302dfb8fa 100755 --- a/app/models/RSSConfiguration.php +++ b/app/models/RSSConfiguration.php @@ -100,7 +100,7 @@ class RSSConfiguration extends Model { return $this->token; } public function autoLoadMore () { - return $this->autoLoadMore; + return $this->auto_load_more; } public function _language ($value) { diff --git a/app/views/configure/display.phtml b/app/views/configure/display.phtml index 932425604..1fdcdee41 100644 --- a/app/views/configure/display.phtml +++ b/app/views/configure/display.phtml @@ -91,6 +91,16 @@ <div class="form-group"> <div class="group-controls"> + <label class="checkbox" for="auto_load_more"> + <input type="checkbox" name="auto_load_more" id="auto_load_more" value="yes"<?php echo $this->conf->autoLoadMore () == 'yes' ? ' checked="checked"' : ''; ?> /> + <?php echo Translate::t ('auto_load_more'); ?> + <?php echo $this->conf->displayPosts () == 'no' ? '<noscript> - <b>' . Translate::t ('javascript_should_be_activated') . '</b></noscript>' : ''; ?> + </label> + </div> + </div> + + <div class="form-group"> + <div class="group-controls"> <label class="checkbox" for="display_posts"> <input type="checkbox" name="display_posts" id="display_posts" value="yes"<?php echo $this->conf->displayPosts () == 'yes' ? ' checked="checked"' : ''; ?> /> <?php echo Translate::t ('display_articles_unfolded'); ?> diff --git a/app/views/javascript/main.phtml b/app/views/javascript/main.phtml index c60093504..efec898e7 100644 --- a/app/views/javascript/main.phtml +++ b/app/views/javascript/main.phtml @@ -7,6 +7,7 @@ var hide_posts = false; <?php $s = $this->conf->shortcuts (); $mark = $this->conf->markWhen (); + $auto_load_more = $this->conf->autoLoadMore () ?> function is_reader_mode() { @@ -210,6 +211,16 @@ function init_posts () { }); }); <?php } ?> + + <?php if ($auto_load_more == 'yes') { ?> + $(window).scroll(function() { + var windowBot = $(window).scrollTop() + $(window).height(); + var load_more_top = $("#load_more").position().top; + if(windowBot >= load_more_top) { + load_more_posts (); + } + }); + <?php } ?> } function init_column_categories () { diff --git a/public/scripts/endless_mode.js b/public/scripts/endless_mode.js index 489b69f30..6b3ef41d5 100644 --- a/public/scripts/endless_mode.js +++ b/public/scripts/endless_mode.js @@ -1,5 +1,5 @@ var url_load_more = ""; -var load = false; +var load_more = false; function init_load_more() { url_load_more = $("a#load_more").attr("href"); @@ -12,7 +12,11 @@ function init_load_more() { } function load_more_posts () { - load = true; + if(load_more == true) { + return; + } + + load_more = true; $("#load_more").addClass("loading"); $.get (url_load_more, function (data) { $("#stream .flux:last").after($("#stream .flux", data)); @@ -22,7 +26,7 @@ function load_more_posts () { init_posts(); $("#load_more").removeClass("loading"); - load = false; + load_more = false; }); } |
