summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2013-06-15 11:02:58 +0200
committerGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2013-06-15 11:02:58 +0200
commit0ff751b443604ccb8cd0eb69050f59298c98a492 (patch)
treec0a66c2a75d8a3c619f0b35c1504a98b13167dc4
parentfb5e5594bea149ca730bc6424dc547dab3347747 (diff)
Lazyload facultatif (issue #75 ok)
-rwxr-xr-xapp/controllers/configureController.php3
-rw-r--r--app/i18n/en.php1
-rw-r--r--app/i18n/fr.php1
-rwxr-xr-xapp/models/RSSConfiguration.php16
-rw-r--r--app/views/configure/display.phtml14
-rw-r--r--app/views/index/index.phtml8
-rw-r--r--app/views/javascript/main.phtml3
7 files changed, 44 insertions, 2 deletions
diff --git a/app/controllers/configureController.php b/app/controllers/configureController.php
index 0d385daf9..4cfc1c085 100755
--- a/app/controllers/configureController.php
+++ b/app/controllers/configureController.php
@@ -142,6 +142,7 @@ class configureController extends ActionController {
$nb = Request::param ('posts_per_page', 10);
$view = Request::param ('default_view', 'all');
$display = Request::param ('display_posts', 'no');
+ $lazyload = Request::param ('lazyload', 'yes');
$sort = Request::param ('sort_order', 'low_to_high');
$old = Request::param ('old_entries', 3);
$mail = Request::param ('mail_login', false);
@@ -154,6 +155,7 @@ class configureController extends ActionController {
$this->view->conf->_postsPerPage (intval ($nb));
$this->view->conf->_defaultView ($view);
$this->view->conf->_displayPosts ($display);
+ $this->view->conf->_lazyload ($lazyload);
$this->view->conf->_sortOrder ($sort);
$this->view->conf->_oldEntries ($old);
$this->view->conf->_mailLogin ($mail);
@@ -169,6 +171,7 @@ class configureController extends ActionController {
'posts_per_page' => $this->view->conf->postsPerPage (),
'default_view' => $this->view->conf->defaultView (),
'display_posts' => $this->view->conf->displayPosts (),
+ 'lazyload' => $this->view->conf->lazyload (),
'sort_order' => $this->view->conf->sortOrder (),
'old_entries' => $this->view->conf->oldEntries (),
'mail_login' => $this->view->conf->mailLogin (),
diff --git a/app/i18n/en.php b/app/i18n/en.php
index 3c3a1fbcc..30bed791f 100644
--- a/app/i18n/en.php
+++ b/app/i18n/en.php
@@ -144,6 +144,7 @@ return array (
'default_view' => 'Default view',
'sort_order' => 'Sort order',
'display_articles_unfolded' => 'Show articles unfolded by default',
+ 'img_with_lazyload' => 'Use "lazy load" mode to load pictures',
'auto_read_when' => 'Mark automatically as read when',
'article_selected' => 'Article is selected',
'article_open_on_website' => 'Article is opened on its original website',
diff --git a/app/i18n/fr.php b/app/i18n/fr.php
index d270c9b96..87b87945f 100644
--- a/app/i18n/fr.php
+++ b/app/i18n/fr.php
@@ -144,6 +144,7 @@ return array (
'default_view' => 'Vue par défaut',
'sort_order' => 'Ordre de tri',
'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 automatiquement comme lu lorsque',
'article_selected' => 'L\'article est sélectionné',
'article_open_on_website' => 'L\'article est ouvert sur le site d\'origine',
diff --git a/app/models/RSSConfiguration.php b/app/models/RSSConfiguration.php
index 00fe3fe52..50dbd2555 100755
--- a/app/models/RSSConfiguration.php
+++ b/app/models/RSSConfiguration.php
@@ -9,6 +9,7 @@ class RSSConfiguration extends Model {
private $posts_per_page;
private $default_view;
private $display_posts;
+ private $lazyload;
private $sort_order;
private $old_entries;
private $shortcuts = array ();
@@ -22,6 +23,7 @@ class RSSConfiguration extends Model {
$this->_postsPerPage ($confDAO->posts_per_page);
$this->_defaultView ($confDAO->default_view);
$this->_displayPosts ($confDAO->display_posts);
+ $this->_lazyload ($confDAO->lazyload);
$this->_sortOrder ($confDAO->sort_order);
$this->_oldEntries ($confDAO->old_entries);
$this->_shortcuts ($confDAO->shortcuts);
@@ -45,6 +47,9 @@ class RSSConfiguration extends Model {
public function displayPosts () {
return $this->display_posts;
}
+ public function lazyload () {
+ return $this->lazyload;
+ }
public function sortOrder () {
return $this->sort_order;
}
@@ -100,6 +105,13 @@ class RSSConfiguration extends Model {
$this->display_posts = 'no';
}
}
+ public function _lazyload ($value) {
+ if ($value == 'no') {
+ $this->lazyload = 'no';
+ } else {
+ $this->lazyload = 'yes';
+ }
+ }
public function _sortOrder ($value) {
if ($value == 'high_to_low') {
$this->sort_order = 'high_to_low';
@@ -144,6 +156,7 @@ class RSSConfigurationDAO extends Model_array {
public $posts_per_page = 20;
public $default_view = 'not_read';
public $display_posts = 'no';
+ public $lazyload = 'yes';
public $sort_order = 'low_to_high';
public $old_entries = 3;
public $shortcuts = array (
@@ -178,6 +191,9 @@ class RSSConfigurationDAO extends Model_array {
if (isset ($this->array['display_posts'])) {
$this->display_posts = $this->array['display_posts'];
}
+ if (isset ($this->array['lazyload'])) {
+ $this->lazyload = $this->array['lazyload'];
+ }
if (isset ($this->array['sort_order'])) {
$this->sort_order = $this->array['sort_order'];
}
diff --git a/app/views/configure/display.phtml b/app/views/configure/display.phtml
index be67896dc..ea4fecd34 100644
--- a/app/views/configure/display.phtml
+++ b/app/views/configure/display.phtml
@@ -68,6 +68,20 @@
</div>
<div class="form-group">
+ <label class="group-name"><?php echo Translate::t ('img_with_lazyload'); ?></label>
+ <div class="group-controls">
+ <label class="radio" for="lazyload_yes">
+ <input type="radio" name="lazyload" id="lazyload_yes" value="yes"<?php echo $this->conf->lazyload () == 'yes' ? ' checked="checked"' : ''; ?> />
+ <?php echo Translate::t ('yes'); ?><noscript> - <b><?php echo Translate::t ('javascript_should_be_activated'); ?></b></noscript>
+ </label>
+ <label class="radio" for="lazyload_no">
+ <input type="radio" name="lazyload" id="lazyload_no" value="no"<?php echo $this->conf->lazyload () == 'no' ? ' checked="checked"' : ''; ?> />
+ <?php echo Translate::t ('no'); ?>
+ </label>
+ </div>
+ </div>
+
+ <div class="form-group">
<label class="group-name"><?php echo Translate::t ('display_articles_unfolded'); ?></label>
<div class="group-controls">
<label class="radio" for="radio_yes">
diff --git a/app/views/index/index.phtml b/app/views/index/index.phtml
index 7037b2405..1a07cdb46 100644
--- a/app/views/index/index.phtml
+++ b/app/views/index/index.phtml
@@ -66,7 +66,13 @@ if ($output == 'rss') {
<h1 class="title"><?php echo $item->title (); ?></h1>
<?php $author = $item->author (); ?>
<?php echo $author != '' ? '<div class="author">' . Translate::t ('by_author', $author) . '</div>' : ''; ?>
- <?php echo lazyimg($item->content ()); ?>
+ <?php
+ if($this->conf->lazyload() == 'yes') {
+ echo lazyimg($item->content ());
+ } else {
+ echo $item->content();
+ }
+ ?>
</div>
<ul class="horizontal-list bottom">
diff --git a/app/views/javascript/main.phtml b/app/views/javascript/main.phtml
index 443f62c31..9596b1647 100644
--- a/app/views/javascript/main.phtml
+++ b/app/views/javascript/main.phtml
@@ -125,8 +125,9 @@ function init_posts () {
<?php } ?>
init_img ();
- // TODO rendre optionnel
+ <?php if($this->conf->lazyload() == 'yes') { ?>
$(".flux .content img").lazyload();
+ <?php } ?>
if (hide_posts) {
$(".flux:not(.active) .flux_content").hide ();