diff options
author | Benaka Moorthi <benaka.moorthi@gmail.com> | 2013-07-19 18:27:58 +0400 |
---|---|---|
committer | Benaka Moorthi <benaka.moorthi@gmail.com> | 2013-07-19 18:27:58 +0400 |
commit | 332e43403992cc114a21cb03aa8296a9a8da16d8 (patch) | |
tree | 9b4ebe724900ead5fe46c8e157d6517998d3b2d0 /core/Twig.php | |
parent | e108ded1a30deeb19317e3604b74e674be111152 (diff) |
Refs #3942, allow server-side and JS UI code to use colors defined in CSS.
Notes:
- Removed colors.piwik.json loading code. No longer necessary.
- UserCountryMap is the only remaining portion of Piwik that doesn't use this technique. Not yet, anyway.
Diffstat (limited to 'core/Twig.php')
-rw-r--r-- | core/Twig.php | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/core/Twig.php b/core/Twig.php index a3f69dbc7e..8e4bcb7c01 100644 --- a/core/Twig.php +++ b/core/Twig.php @@ -18,6 +18,9 @@ */ class Piwik_Twig { + const SPARKLINE_TEMPLATE = '<img class="sparkline" alt="" data-src="%s" width="%d" height="%d" /> + <script type="text/javascript">$(document).ready(function () { piwik.initSparklines(); });</script>'; + /** * @var Twig_Environment */ @@ -90,10 +93,9 @@ class Piwik_Twig protected function addFunction_sparkline() { $sparklineFunction = new Twig_SimpleFunction('sparkline', function ($src) { - $graph = new Piwik_Visualization_Sparkline(); - $width = $graph->getWidth(); - $height = $graph->getHeight(); - return sprintf('<img class="sparkline" alt="" src="%s" width="%d" height="%d" />', $src, $width, $height); + $width = Piwik_Visualization_Sparkline::DEFAULT_WIDTH; + $height = Piwik_Visualization_Sparkline::DEFAULT_HEIGHT; + return sprintf(Piwik_Twig::SPARKLINE_TEMPLATE, $src, $width, $height); }, array('is_safe' => array('html'))); $this->twig->addFunction($sparklineFunction); } |