summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2013-11-03 19:22:59 +0100
committerGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2013-11-04 23:31:36 +0100
commit231516f5238b6023001bed548569077c61411a4e (patch)
tree2265c174152f3bc7c0fbe49f5a776bc4ca5c3020 /app
parentb23d66ec360208cf1e1d8ee2fc3bebf25997d9fa (diff)
Grosse optimisation JavaScript
* Fusion de endless_mode.js dans main.js car endless_mode.js est toujours chargé et assez petit. * Suppression des changements de style en JavaScript lors du chargement (genre boucle de .hide(), ou d'ajout de classe ".stick") et implémentation en PHP + CSS à la place. * Chargement JavaScript asynchrone (defer + async) pour de meilleurs performances. * Utilisation préférable des événements globaux plutôt que des événements pour chaque élément avec jQuery.on(events, selector) pour un chargement plus rapide et moins de mémoire utilisée. * Optimisation manuelle du JavaScript (sélecteurs CSS plus performants, méthodes jQuery plus appropriées, etc.). * Désactivation de init_img() qui était coûteux, lancé à un moment où les images ne sont de toute manière pas encore chargées, et qui n'apporte rien car il y a déjà un img {max-width:100%} en CSS. * JavaScript en mode strict. * Enfin, passage du code JavaScript dans JSLint et du coup nombreuses corrections (syntaxe, variables, méthodes dépréciées...). * Devrait permettre de fermer https://github.com/marienfressinaud/FreshRSS/issues/121 * Au passage, quelques simplifications CSS pour de meilleures performances.
Diffstat (limited to 'app')
-rwxr-xr-xapp/controllers/indexController.php1
-rw-r--r--app/layout/aside_flux.phtml3
-rw-r--r--app/layout/layout.phtml1
-rw-r--r--app/layout/nav_entries.phtml2
-rw-r--r--app/models/Feed.php2
-rw-r--r--app/views/helpers/view/global_view.phtml2
-rw-r--r--app/views/helpers/view/normal_view.phtml9
-rw-r--r--app/views/javascript/main.phtml14
8 files changed, 17 insertions, 17 deletions
diff --git a/app/controllers/indexController.php b/app/controllers/indexController.php
index 9f71c0e57..15b0b1d18 100755
--- a/app/controllers/indexController.php
+++ b/app/controllers/indexController.php
@@ -18,7 +18,6 @@ class indexController extends ActionController {
View::appendScript (Url::display ('/scripts/shortcut.js'));
View::appendScript (Url::display ('/scripts/main.js'));
- View::appendScript (Url::display ('/scripts/endless_mode.js'));
if ($output == 'global') {
View::appendScript (Url::display ('/scripts/global_view.js'));
diff --git a/app/layout/aside_flux.phtml b/app/layout/aside_flux.phtml
index 22f52d25a..f661eadd4 100644
--- a/app/layout/aside_flux.phtml
+++ b/app/layout/aside_flux.phtml
@@ -51,8 +51,9 @@
<?php if (!empty ($feeds)) { ?>
<li>
<?php $c_active = false; if ($this->get_c == $cat->id ()) { $c_active = true; } ?>
- <div class="category<?php echo $c_active ? ' active' : ''; ?>">
+ <div class="category stick<?php echo $c_active ? ' active' : ''; ?>">
<a data-unread="<?php echo $cat->nbNotRead (); ?>" class="btn<?php echo $c_active ? ' active' : ''; ?>" href="<?php echo _url ('index', 'index', 'get', 'c_' . $cat->id ()); ?>"><?php echo $cat->name (); ?></a>
+ <a class="btn dropdown-toggle" href="#"><i class="icon <?php echo $c_active ? 'i_up' : 'i_down'; ?>"></i></a>
</div>
<ul class="feeds<?php echo $c_active ? ' active' : ''; ?>">
diff --git a/app/layout/layout.phtml b/app/layout/layout.phtml
index 7f389463e..cfbdc4a2e 100644
--- a/app/layout/layout.phtml
+++ b/app/layout/layout.phtml
@@ -8,6 +8,7 @@
<?php echo self::headTitle (); ?>
<?php echo self::headStyle (); ?>
+ <?php echo self::headScript (); ?>
<script>//<![CDATA[
<?php $this->renderHelper ('../javascript/main'); ?>
//]]></script>
diff --git a/app/layout/nav_entries.phtml b/app/layout/nav_entries.phtml
index 5501f1725..3c3c3ae5e 100644
--- a/app/layout/nav_entries.phtml
+++ b/app/layout/nav_entries.phtml
@@ -1,4 +1,4 @@
-<ul class="nav_entries">
+<ul id="nav_entries">
<li class="item"><a class="previous_entry" href="#"><i class="icon i_prev"></i></a></li>
<li class="item"><a class="up" href="#"><i class="icon i_up"></i></a></li>
<li class="item"><a class="next_entry" href="#"><i class="icon i_next"></i></a></li>
diff --git a/app/models/Feed.php b/app/models/Feed.php
index 14eeb942a..d3e429b22 100644
--- a/app/models/Feed.php
+++ b/app/models/Feed.php
@@ -171,7 +171,7 @@ class Feed extends Model {
}
public function _nbNotRead ($value) {
$this->nbNotRead = is_numeric ($value) ? intval ($value) : -1;
- }
+ }
public function _nbEntries ($value) {
$this->nbEntries = is_numeric ($value) ? intval ($value) : -1;
}
diff --git a/app/views/helpers/view/global_view.phtml b/app/views/helpers/view/global_view.phtml
index 131152f27..9fd7d9863 100644
--- a/app/views/helpers/view/global_view.phtml
+++ b/app/views/helpers/view/global_view.phtml
@@ -37,6 +37,6 @@
</div>
<div id="overlay"></div>
-<div id="panel">
+<div id="panel"<?php echo $this->conf->displayPosts () === 'no' ? ' class="hide_posts"' : ''; ?>>
<a class="close" href="#"><i class="icon i_close"></i></a>
</div> \ No newline at end of file
diff --git a/app/views/helpers/view/normal_view.phtml b/app/views/helpers/view/normal_view.phtml
index 88fc602f6..46547587f 100644
--- a/app/views/helpers/view/normal_view.phtml
+++ b/app/views/helpers/view/normal_view.phtml
@@ -7,7 +7,7 @@ if (isset ($this->entryPaginator) && !$this->entryPaginator->isEmpty ()) {
$items = $this->entryPaginator->items ();
?>
-<div id="stream" class="normal">
+<div id="stream" class="normal<?php echo $this->conf->displayPosts () === 'no' ? ' hide_posts' : ''; ?>">
<?php
$display_today = true;
$display_yesterday = true;
@@ -77,7 +77,7 @@ if (isset ($this->entryPaginator) && !$this->entryPaginator->isEmpty ()) {
$link = urlencode ($item->link ());
$title = urlencode ($item->title () . ' - ' . $feed->name ());
?>
- <div class="dropdown">
+ <div class="dropdown">
<div id="dropdown-share-<?php echo $item->id ();?>" class="dropdown-target"></div>
<i class="icon i_share"></i> <a class="dropdown-toggle" href="#dropdown-share-<?php echo $item->id ();?>"><?php echo Translate::t ('share'); ?></a>
@@ -85,8 +85,8 @@ if (isset ($this->entryPaginator) && !$this->entryPaginator->isEmpty ()) {
<li class="dropdown-close"><a href="#close">&nbsp;</a></li>
<?php
- $shaarli = $this->conf->urlShaarli ();
- if ((!login_is_conf ($this->conf) || is_logged ()) && $shaarli) {
+ $shaarli = $this->conf->urlShaarli ();
+ if ((!login_is_conf ($this->conf) || is_logged ()) && $shaarli) {
?>
<li class="item">
<a target="_blank" href="<?php echo $shaarli . '?post=' . $link . '&amp;title=' . $title . '&amp;source=bookmarklet'; ?>">
@@ -128,7 +128,6 @@ if (isset ($this->entryPaginator) && !$this->entryPaginator->isEmpty ()) {
<ul class="dropdown-menu">
<li class="dropdown-close"><a href="#close">&nbsp;</a></li>
-
<?php foreach($tags as $tag) { ?>
<li class="item"><a href="<?php echo _url ('index', 'index', 'search', urlencode ('#' . $tag)); ?>"><?php echo $tag; ?></a></li>
<?php } ?>
diff --git a/app/views/javascript/main.phtml b/app/views/javascript/main.phtml
index 82ed8ff18..7adb57037 100644
--- a/app/views/javascript/main.phtml
+++ b/app/views/javascript/main.phtml
@@ -1,13 +1,13 @@
<?php
+ echo '"use strict";', "\n";
$mark = $this->conf->markWhen ();
echo 'var ',
- 'hide_posts=', $this->conf->displayPosts () === 'no' ? 'true,' : 'false,',
- 'hide_posts=', $this->conf->displayPosts () === 'no' ? 'true,' : 'false,',
- 'auto_mark_article=', $mark['article'] === 'yes' ? 'true,' : 'false,',
- 'auto_mark_site=', $mark['site'] === 'yes' ? 'true,' : 'false,',
- 'auto_mark_scroll=', $mark['scroll'] === 'yes' ? 'true,' : 'false,',
- 'auto_load_more=', $this->conf->autoLoadMore () === 'yes' ? 'true,' : 'false,',
- 'does_lazyload=', $this->conf->lazyload() === 'yes' ? 'true' : 'false', ";\n";
+ 'hide_posts=', ($this->conf->displayPosts () === 'yes' || Request::param ('output') === 'reader') ? 'false' : 'true',
+ ',auto_mark_article=', $mark['article'] === 'yes' ? 'true' : 'false',
+ ',auto_mark_site=', $mark['site'] === 'yes' ? 'true' : 'false',
+ ',auto_mark_scroll=', $mark['scroll'] === 'yes' ? 'true' : 'false',
+ ',auto_load_more=', $this->conf->autoLoadMore () === 'yes' ? 'true' : 'false',
+ ',does_lazyload=', $this->conf->lazyload() === 'yes' ? 'true' : 'false', ";\n";
$s = $this->conf->shortcuts ();
echo 'var shortcuts={',