Skip to content

Commit

Permalink
refs #4338 highlight changelog tab if needed
Browse files Browse the repository at this point in the history
  • Loading branch information
tsteur committed Nov 27, 2013
1 parent 07297be commit 8f65d0a
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 5 deletions.
5 changes: 5 additions & 0 deletions plugins/CorePluginsAdmin/Controller.php
Expand Up @@ -126,6 +126,10 @@ public function pluginDetails()
static::dieIfMarketplaceIsDisabled();

$pluginName = Common::getRequestVar('pluginName', null, 'string');
$activeTab = Common::getRequestVar('activeTab', '', 'string');
if ('changelog' !== $activeTab) {
$activeTab = '';
}

$view = $this->configureView('@CorePluginsAdmin/pluginDetails');

Expand All @@ -135,6 +139,7 @@ public function pluginDetails()
$view->isSuperUser = Piwik::isUserIsSuperUser();
$view->installNonce = Nonce::getNonce(static::INSTALL_NONCE);
$view->updateNonce = Nonce::getNonce(static::UPDATE_NONCE);
$view->activeTab = $activeTab;
} catch (\Exception $e) {
$view->errorMessage = $e->getMessage();
}
Expand Down
22 changes: 20 additions & 2 deletions plugins/CorePluginsAdmin/javascripts/pluginDetail.js
Expand Up @@ -51,17 +51,35 @@ $(document).ready(function () {
return;
}

var pluginName = $( this ).attr('data-pluginName');
var pluginName = $(this).attr('data-pluginName');

if (!pluginName) {
return;
}

var activeTab = $(event.target).attr('data-activePluginTab');
if (activeTab) {
pluginName += '!' + activeTab;
}

broadcast.propagateNewPopoverParameter('browsePluginDetail', pluginName);
});

var showPopover = function (pluginName) {
var showPopover = function (value) {
var pluginName = value;
var activeTab = null;

if (-1 !== value.indexOf('!')) {
activeTab = value.substr(value.indexOf('!') + 1);
pluginName = value.substr(0, value.indexOf('!'));
}

var url = 'module=CorePluginsAdmin&action=pluginDetails&pluginName=' + encodeURIComponent(pluginName);

if (activeTab) {
url += '&activeTab=' + encodeURIComponent(activeTab);
}

Piwik_Popover.createPopupAndLoadUrl(url, 'details');
};

Expand Down
3 changes: 3 additions & 0 deletions plugins/CorePluginsAdmin/stylesheets/marketplace.less
Expand Up @@ -232,6 +232,9 @@
color: #9b7a44;
font-weight: bold;
}
a:hover {
text-decoration: underline;
}
}

p, .ui-tabs-panel ul, .ui-tabs-panel li {
Expand Down
2 changes: 1 addition & 1 deletion plugins/CorePluginsAdmin/templates/macros.twig
Expand Up @@ -21,7 +21,7 @@
</td>
<td class="vers">
{% if plugin.repositoryChangelogUrl %}
<a title="Changelog" target="_blank" href="{{ plugin.repositoryChangelogUrl }}">{{ plugin.currentVersion }} => {{ plugin.latestVersion }}</a>
<a href="javascript:return;" title="Changelog" data-activePluginTab="changelog" data-pluginName="{{ plugin.name|e('html_attr') }}">{{ plugin.currentVersion }} => {{ plugin.latestVersion }}</a>
{% else %}
{{ plugin.currentVersion }} => {{ plugin.latestVersion }}
{% endif %}
Expand Down
12 changes: 11 additions & 1 deletion plugins/CorePluginsAdmin/templates/pluginDetails.twig
Expand Up @@ -172,7 +172,17 @@
</div>
<script type="text/javascript">
$(function() {
$( "#pluginDetailsTabs" ).tabs();
var active = 0;
{% if activeTab %}
var $activeTab = $('#tabs-{{ activeTab|e('js') }}');
if ($activeTab) {
active = $activeTab.index() - 1;
}
{% endif %}
$( "#pluginDetailsTabs" ).tabs({active: active >= 0 ? active : 0});
$('.pluginDetails a').each(function (index, a) {
var link = $(a).attr('href');
Expand Down
2 changes: 1 addition & 1 deletion plugins/CorePluginsAdmin/templates/pluginOverview.twig
Expand Up @@ -22,5 +22,5 @@
<a href="javascript:return;" title="Click for more details" class="more">&gt;&gt; more</a>
</p>
{% if plugin.canBeUpdated %}
<p class="updateAvailableNotice">You can update this plugin from version {{ plugin.currentVersion }} to {{ plugin.latestVersion }}</p>
<p class="updateAvailableNotice" data-activePluginTab="changelog">You can update this plugin from version {{ plugin.currentVersion }} to {{ plugin.latestVersion }}</p>
{% endif %}

0 comments on commit 8f65d0a

Please sign in to comment.