aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2013-12-14 13:57:25 +0100
committerGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2013-12-14 13:57:25 +0100
commit4f0b1efc2b6334a5be1e5f2b6a7b64b925c841b4 (patch)
tree589fbcf78367e8f74458ef4d12a922fe2353db72
parent97a7d7b0b2c25d573a8dac72e6183abf640c8fe4 (diff)
Prefectch : précharge les icônes
Précharge les icônes qui ne sont pas forcément affichées sur la page en cours (par exemple l'icône favoris) pour éviter d'avoir un bref instant sans icône lors du changement d'état (par exemple lorsqu'on marque un article comme favoris)
-rw-r--r--app/layout/layout.phtml4
-rw-r--r--app/models/RSSThemes.php5
2 files changed, 7 insertions, 2 deletions
diff --git a/app/layout/layout.phtml b/app/layout/layout.phtml
index 6fc5c1cf0..ac00e8fd0 100644
--- a/app/layout/layout.phtml
+++ b/app/layout/layout.phtml
@@ -20,6 +20,10 @@
<?php if (isset ($this->rss_url)) { ?>
<link rel="alternate" type="application/rss+xml" title="<?php echo $this->rss_title; ?>" href="<?php echo Url::display ($this->rss_url); ?>" />
<?php } ?>
+ <link rel="prefetch" href="<?php echo RSSThemes::icon('starred', true); ?>">
+ <link rel="prefetch" href="<?php echo RSSThemes::icon('non-starred', true); ?>">
+ <link rel="prefetch" href="<?php echo RSSThemes::icon('read', true); ?>">
+ <link rel="prefetch" href="<?php echo RSSThemes::icon('unread', true); ?>">
<meta name="robots" content="noindex,nofollow" />
</head>
<body>
diff --git a/app/models/RSSThemes.php b/app/models/RSSThemes.php
index 7a6deaf3c..a3e67f8b1 100644
--- a/app/models/RSSThemes.php
+++ b/app/models/RSSThemes.php
@@ -47,7 +47,7 @@ class RSSThemes extends Model {
), 1) : array();
}
- public static function icon($name) {
+ public static function icon($name, $urlOnly = false) {
static $alts = array(
'add' => '✚',
'all' => '☰',
@@ -82,6 +82,7 @@ class RSSThemes extends Model {
$url = isset(self::$themeIcons[$url]) ? (self::$themeIconsUrl . $url) :
(self::$defaultIconsUrl . $url);
- return '<img class="icon" src="' . Url::display($url) . '" alt="' . $alts[$name] . '" />';
+ return $urlOnly ? Url::display($url) :
+ '<img class="icon" src="' . Url::display($url) . '" alt="' . $alts[$name] . '" />';
}
}