From 371d636c712a4c62c6786d3af5edbf483b995a7c Mon Sep 17 00:00:00 2001 From: benakamoorthi <benaka.moorthi@gmail.com> Date: Tue, 24 Jul 2012 09:12:20 +0000 Subject: [PATCH] Refs #3184, added ability to specify custom tooltips for datatable labels & modified Referers>Websites table to show full referer url as the tooltip. Also tweaked tooltip CSS style. git-svn-id: http://dev.piwik.org/svn/trunk@6546 59fd770c-687e-43c8-a1e3-f5a4ff64c105 --- core/ViewDataTable.php | 9 +++++++++ plugins/CoreHome/templates/datatable.js | 20 ++++++++++++++++++- plugins/CoreHome/templates/datatable_cell.tpl | 4 ++-- plugins/Referers/Controller.php | 1 + themes/default/common.css | 7 ++++--- 5 files changed, 35 insertions(+), 6 deletions(-) diff --git a/core/ViewDataTable.php b/core/ViewDataTable.php index a858fed32e..4992ef2724 100644 --- a/core/ViewDataTable.php +++ b/core/ViewDataTable.php @@ -311,6 +311,7 @@ abstract class Piwik_ViewDataTable $this->viewProperties['relatedReports'] = array(); $this->viewProperties['title'] = 'unknown'; $this->viewProperties['self_url'] = $this->getBaseReportUrl($currentControllerName, $currentControllerAction); + $this->viewProperties['tooltip_metadata_name'] = false; $standardColumnNameToTranslation = array_merge( Piwik_API_API::getInstance()->getDefaultMetrics(), @@ -1250,6 +1251,14 @@ abstract class Piwik_ViewDataTable $this->viewProperties['highlight_summary_row'] = $highlightSummaryRow; } + /** + * Sets the name of the metadata to use for a custom tooltip. + */ + public function setTooltipMetadataName( $metadataName ) + { + $this->viewProperties['tooltip_metadata_name'] = $metadataName; + } + /** * Sets columns translations array. * diff --git a/plugins/CoreHome/templates/datatable.js b/plugins/CoreHome/templates/datatable.js index b9372ef9e0..c6a97d8d2f 100644 --- a/plugins/CoreHome/templates/datatable.js +++ b/plugins/CoreHome/templates/datatable.js @@ -939,7 +939,25 @@ dataTable.prototype = truncationLimit += truncationOffset; domElemToTruncate.truncate(truncationLimit); - $('.truncated', domElemToTruncate).tooltip(); + var tooltipElem = $('.truncated', domElemToTruncate), + customToolTipText = domElemToTruncate.attr('title'); + + // if there's a title on the dom element, use this as the tooltip instead of + // the one set by the truncate plugin + if (customToolTipText) + { + // make sure browser doesn't add its own tooltip for the truncated element + if (tooltipElem[0]) + { + tooltipElem.removeAttr('title'); + } + + tooltipElem = domElemToTruncate; + tooltipElem.attr('title', customToolTipText); + } + + // use tooltip (tooltip text determined by the 'title' attribute) + tooltipElem.tooltip(); }, //Apply some miscelleaneous style to the DataTable diff --git a/plugins/CoreHome/templates/datatable_cell.tpl b/plugins/CoreHome/templates/datatable_cell.tpl index 0ba698ab44..a4f335a0a1 100644 --- a/plugins/CoreHome/templates/datatable_cell.tpl +++ b/plugins/CoreHome/templates/datatable_cell.tpl @@ -15,10 +15,10 @@ {/if} {if $column=='label'} {logoHtml metadata=$row.metadata alt=$row.columns.label} - <span class='label{if !empty($row.metadata.is_aggregate) && $row.metadata.is_aggregate } highlighted{/if}'>{* make sure there are no whitespaces inside the span + <span class='label{if !empty($row.metadata.is_aggregate) && $row.metadata.is_aggregate } highlighted{/if}' {if !empty($properties.tooltip_metadata_name)}title="{$row.metadata[$properties.tooltip_metadata_name]}"{/if}>{* make sure there are no whitespaces inside the span *}{/if}{* *}{if isset($row.columns[$column])}{$row.columns[$column]}{else}{$defaultWhenColumnValueNotDefined}{/if}{* *}{if $column=='label'}</span>{/if} {if !$row.idsubdatatable && $column=='label' && !empty($row.metadata.url)} </a> -{/if} \ No newline at end of file +{/if} diff --git a/plugins/Referers/Controller.php b/plugins/Referers/Controller.php index 84942ff64e..8f0df033b1 100644 --- a/plugins/Referers/Controller.php +++ b/plugins/Referers/Controller.php @@ -216,6 +216,7 @@ class Piwik_Referers_Controller extends Piwik_Controller $view->disableExcludeLowPopulation(); $view->setColumnsToDisplay( array('label','nb_visits') ); $view->setColumnTranslation('label', Piwik_Translate('Referers_ColumnWebsitePage')); + $view->setTooltipMetadataName('url'); return $this->renderView($view, $fetch); } diff --git a/themes/default/common.css b/themes/default/common.css index 91cdc1d96a..8c63dc0b68 100644 --- a/themes/default/common.css +++ b/themes/default/common.css @@ -374,7 +374,8 @@ a { #tooltip h3 { font-weight: normal; - font-size:1em; + font-size:.85em; + font-style: italic; color:#162540; margin:0; padding:0; @@ -382,8 +383,8 @@ a { #tooltip { position: absolute; z-index: 3000; - border: 1px solid #111; - padding:7px; + border: 1px solid #E4E2D7 /*#111*/; + padding:5px 7px 5px 7px; background-color:#F5F7FF; opacity:0.95; } -- GitLab