From 1d459af0464eb2cdbdaaaf1122e1681210fdffea Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Fri, 14 Jun 2013 20:45:00 +0200 Subject: Fix issue #75 : chargement des images en lazyload, reste à le rendre optionnel MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/javascript/main.phtml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'app/views/javascript') diff --git a/app/views/javascript/main.phtml b/app/views/javascript/main.phtml index e6c882333..443f62c31 100644 --- a/app/views/javascript/main.phtml +++ b/app/views/javascript/main.phtml @@ -109,8 +109,8 @@ function mark_favorite (active) { } function init_img () { - $(".flux .content img").each (function () { - if ($(this).width () > ($("#stream .content").width()) / 2) { + $(".flux_content .content img").each (function () { + if ($(this).width () > ($(".flux_content .content").width()) / 2) { $(this).addClass("big"); } }); @@ -125,6 +125,8 @@ function init_posts () { init_img (); + // TODO rendre optionnel + $(".flux .content img").lazyload(); if (hide_posts) { $(".flux:not(.active) .flux_content").hide (); -- cgit v1.2.3 From 0ff751b443604ccb8cd0eb69050f59298c98a492 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sat, 15 Jun 2013 11:02:58 +0200 Subject: Lazyload facultatif (issue #75 ok) --- app/controllers/configureController.php | 3 +++ app/i18n/en.php | 1 + app/i18n/fr.php | 1 + app/models/RSSConfiguration.php | 16 ++++++++++++++++ app/views/configure/display.phtml | 14 ++++++++++++++ app/views/index/index.phtml | 8 +++++++- app/views/javascript/main.phtml | 3 ++- 7 files changed, 44 insertions(+), 2 deletions(-) (limited to 'app/views/javascript') 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 @@ -67,6 +67,20 @@ +
+ +
+ + +
+
+
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') {

title (); ?>

author (); ?> ' . Translate::t ('by_author', $author) . '
' : ''; ?> - content ()); ?> + conf->lazyload() == 'yes') { + echo lazyimg($item->content ()); + } else { + echo $item->content(); + } + ?>