From a3c89871ddcc6f570020450b52dd41f78f46fa23 Mon Sep 17 00:00:00 2001
From: BeezyT <timo@ezdesign.de>
Date: Wed, 14 Nov 2012 14:04:52 +0000
Subject: [PATCH] refs #2465

 * row evolution and transitions can be launched from the sidebar
 * when launching overlay, always pick date "current month"
 * make sure there never are two scrollbars when the window is not high enough

git-svn-id: http://dev.piwik.org/svn/trunk@7473 59fd770c-687e-43c8-a1e3-f5a4ff64c105
---
 plugins/Overlay/Controller.php               |  2 ++
 plugins/Overlay/templates/index.css          | 38 +++++++++++++++++---
 plugins/Overlay/templates/index.js           | 35 ++++++++++++++++--
 plugins/Overlay/templates/index.tpl          |  3 ++
 plugins/Overlay/templates/rowaction.js       |  3 +-
 plugins/Overlay/templates/sidebar.tpl        |  5 ++-
 plugins/Transitions/templates/transitions.js |  7 +++-
 7 files changed, 82 insertions(+), 11 deletions(-)

diff --git a/plugins/Overlay/Controller.php b/plugins/Overlay/Controller.php
index 0c10d1e230..ecb5192108 100644
--- a/plugins/Overlay/Controller.php
+++ b/plugins/Overlay/Controller.php
@@ -112,6 +112,8 @@ class Piwik_Overlay_Controller extends Piwik_Controller
 		$view = Piwik_View::factory('sidebar');
 		$view->data = $data;
 		$view->location = $page;
+		$view->normalizedUrl = $normalizedCurrentUrl;
+		$view->label = $label;
 		$view->idSite = $idSite;
 		$view->period = $period;
 		$view->date = $date;
diff --git a/plugins/Overlay/templates/index.css b/plugins/Overlay/templates/index.css
index d142c7f8b4..42efdcf0dd 100644
--- a/plugins/Overlay/templates/index.css
+++ b/plugins/Overlay/templates/index.css
@@ -1,4 +1,15 @@
 
+html {
+	width: 100%;
+	height: 100%;
+}
+
+body {
+	width: 100%;
+	height: 100%;
+	overflow: hidden;
+}
+
 body #header {
 	margin-left: -12px;
 }
@@ -48,18 +59,35 @@ body h1 {
 	color: #255792;
 }
 
-a#Overlay_FullScreen {
+a#Overlay_FullScreen,
+a#Overlay_RowEvolution,
+a#Overlay_Transitions {
 	display: block;
 	color: #255792;
 	font-size: 13px;
 	line-height: 15px;
-	margin: 20px 0 0 5px;
-	padding: 8px 0 3px 22px;
-	background: url(../../../themes/default/images/fullscreen.png) no-repeat 0 8px;
+	margin: 0 0 0 5px;
+	padding: 8px 0 3px 25px;
 	text-decoration: none;
 }
 
-a#Overlay_FullScreen:hover {
+a#Overlay_RowEvolution {
+	margin-top: 20px;
+	background: url(../../../themes/default/images/row_evolution_hover.png) no-repeat 0 7px;
+}
+
+a#Overlay_Transitions {
+	background: url(../../Transitions/templates/transitions_icon_hover.png) no-repeat 0 6px;
+}
+
+a#Overlay_FullScreen {
+	margin-top: 20px;
+	background: url(../../../themes/default/images/fullscreen.png) no-repeat 3px 8px;
+}
+
+a#Overlay_FullScreen:hover,
+a#Overlay_RowEvolution:hover,
+a#Overlay_Transitions:hover {
 	color: #E87500;
 }
 
diff --git a/plugins/Overlay/templates/index.js b/plugins/Overlay/templates/index.js
index 02521af8dd..42116e62e6 100644
--- a/plugins/Overlay/templates/index.js
+++ b/plugins/Overlay/templates/index.js
@@ -7,7 +7,8 @@
 
 var Piwik_Overlay = (function() {
 
-	var $body, $iframe, $sidebar, $main, $location, $loading, $errorNotLoading, $fullScreenLink;
+	var $body, $iframe, $sidebar, $main, $location, $loading, $errorNotLoading;
+	var $rowEvolutionLink, $transitionsLink, $fullScreenLink;
 
 	var idSite, period, date;
 
@@ -16,6 +17,8 @@ var Piwik_Overlay = (function() {
 	var iframeSrcBase;
 	var iframeDomain = '';
 	var iframeCurrentPage = '';
+	var iframeCurrentPageNormalized = '';
+	var iframeCurrentActionLabel = '';
 	var updateComesFromInsideFrame = false;
 
 
@@ -38,6 +41,8 @@ var Piwik_Overlay = (function() {
 
 			var $responseLocation = $response.find('.Overlay_Location');
 			var $url = $responseLocation.find('span');
+			iframeCurrentPageNormalized = $url.data('normalizedUrl');
+			iframeCurrentActionLabel = $url.data('label');
 			$url.html(piwikHelper.addBreakpointsToUrl($url.text()));
 			$location.html($responseLocation.html()).show();
 			$responseLocation.remove();
@@ -53,13 +58,18 @@ var Piwik_Overlay = (function() {
 			});
 
 			$sidebar.empty().append($response).show();
+			
+			if ($sidebar.find('.Overlay_NoData').size() == 0) {
+				$rowEvolutionLink.show();
+				$transitionsLink.show()
+			}
 		}, 'html');
 	}
 
 	/** Adjust the dimensions of the iframe */
 	function adjustDimensions() {
 		$iframe.height($(window).height());
-		$iframe.width($body.width() - $iframe.offset().left - 2);
+		$iframe.width($body.width() - $iframe.offset().left - 2); // -2 because of 2px border
 	}
 
 	/** Display the loading message and hide other containers */
@@ -68,7 +78,11 @@ var Piwik_Overlay = (function() {
 
 		$sidebar.hide();
 		$location.hide();
+
 		$fullScreenLink.hide();
+		$rowEvolutionLink.hide();
+		$transitionsLink.hide();
+
 		$errorNotLoading.hide();
 
 		// Start a timeout that shows an error when nothing is loaded
@@ -123,6 +137,9 @@ var Piwik_Overlay = (function() {
 			$main = $('#Overlay_Main');
 			$loading = $('#Overlay_Loading');
 			$errorNotLoading = $('#Overlay_Error_NotLoading');
+
+			$rowEvolutionLink = $('#Overlay_RowEvolution');
+			$transitionsLink = $('#Overlay_Transitions');
 			$fullScreenLink = $('#Overlay_FullScreen');
 
 			adjustDimensions();
@@ -164,6 +181,20 @@ var Piwik_Overlay = (function() {
 				$select.prepend('<option selected="selected">');
 			}
 
+			// handle transitions link
+			$transitionsLink.click(function() {
+				var transitions = new Piwik_Transitions('url', iframeCurrentPageNormalized, null);
+				transitions.showPopover();
+				return false;
+			});
+
+			// handle row evolution link
+			$rowEvolutionLink.click(function() {
+				var rowEvolution = new DataTable_RowActions_RowEvolution(null);
+				rowEvolution.showRowEvolution('Actions.getPageUrls', iframeCurrentActionLabel, '0');
+				return false;
+			});
+
 			// handle full screen link
 			$fullScreenLink.click(function() {
 				var href = iframeSrcBase;
diff --git a/plugins/Overlay/templates/index.tpl b/plugins/Overlay/templates/index.tpl
index 192416287a..cd03e8d018 100644
--- a/plugins/Overlay/templates/index.tpl
+++ b/plugins/Overlay/templates/index.tpl
@@ -33,6 +33,9 @@
 
 <div id="Overlay_Sidebar"></div>
 
+<a id="Overlay_RowEvolution">{'CoreHome_RowEvolutionRowActionTooltipTitle_js'|translate|escape:'html'}</a>
+<a id="Overlay_Transitions">{'CoreHome_TransitionsRowActionTooltipTitle_js'|translate|escape:'html'}</a>
+
 <a id="Overlay_FullScreen" href="#">
 	{'Overlay_OpenFullScreen'|translate|escape:'html'}
 </a>
diff --git a/plugins/Overlay/templates/rowaction.js b/plugins/Overlay/templates/rowaction.js
index 24ccb80350..9adc0fbb2d 100644
--- a/plugins/Overlay/templates/rowaction.js
+++ b/plugins/Overlay/templates/rowaction.js
@@ -24,8 +24,7 @@ DataTable_RowActions_Overlay.prototype.onClick = function(actionA, tr, e) {
 		
 		actionA.attr({
 			target: '_blank',
-			href: Overlay_Helper.getOverlayLink(this.dataTable.param.idSite, this.dataTable.param.period,
-				this.dataTable.param.date, link)
+			href: Overlay_Helper.getOverlayLink(this.dataTable.param.idSite, 'month', 'today', link)
 		});
 	}
 	
diff --git a/plugins/Overlay/templates/sidebar.tpl b/plugins/Overlay/templates/sidebar.tpl
index 9f3f4ca7e0..2421fe9791 100644
--- a/plugins/Overlay/templates/sidebar.tpl
+++ b/plugins/Overlay/templates/sidebar.tpl
@@ -3,7 +3,9 @@
 	<!-- This div is removed by JS and the content is put in the location div -->
 	<div class="Overlay_Location">
 		<b>{'Overlay_Location'|translate|escape:'html'}:</b> 
-		<span>{$location|escape:'html'}</span>
+		<span data-normalized-url="{$normalizedUrl|escape:'html'}" data-label="{$label|escape:'html'}">
+			{$location|escape:'html'}
+		</span>
 	</div>
 	
 	{if count($data)}
@@ -14,6 +16,7 @@
 			</div>
 		{/foreach}
 	{else}
+		<!-- note: the class Overlay_NoData is used in index.js -->
 		<div class="Overlay_NoData">{'Overlay_NoData'|translate|escape:'html'}</div>
 	{/if}
 	
diff --git a/plugins/Transitions/templates/transitions.js b/plugins/Transitions/templates/transitions.js
index 6ceb292f69..2dec90d31e 100644
--- a/plugins/Transitions/templates/transitions.js
+++ b/plugins/Transitions/templates/transitions.js
@@ -620,7 +620,12 @@ Piwik_Transitions.prototype.renderClosedGroup = function(groupName, side, onlyBg
 
 /** Reload the entire popover for a different URL */
 Piwik_Transitions.prototype.reloadPopover = function(url) {
-	this.rowAction.openPopover(this.actionType + ':' + url);
+	if (this.rowAction) {
+		this.rowAction.openPopover(this.actionType + ':' + url);
+	} else {
+		this.reset(this.actionType, url);
+		this.showPopover();
+	}
 };
 
 /** Redraw the left or right sides with a different group opened */
-- 
GitLab