Skip to content

Commit

Permalink
refs #4987 apply a max width of 1200px, add a separator before switch…
Browse files Browse the repository at this point in the history
…, use alt+f instead of alt+s
  • Loading branch information
tsteur committed May 19, 2014
1 parent 37cafff commit b02e74e
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 8 deletions.
37 changes: 32 additions & 5 deletions plugins/CoreHome/javascripts/dataTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,13 @@ $.extend(DataTable.prototype, UIControl.prototype, {
setFixWidthToMakeEllipsisWork: function (domElem) {
var self = this;

function getTableWidth(domElem) {
function isWidgetized()
{
return -1 !== location.search.indexOf('module=Widgetize');
}

function getTableWidth(domElem)
{
var totalWidth = $(domElem).width();
var totalWidthTable = $('table.dataTable', domElem).width(); // fixes tables in dbstats, referrers, ...

Expand All @@ -321,6 +327,28 @@ $.extend(DataTable.prototype, UIControl.prototype, {
return parseInt(totalWidth, 10);
}

function setMaxTableWidthIfNeeded (domElem, maxTableWidth)
{
var tableWidth = getTableWidth(domElem);

if (tableWidth <= maxTableWidth) {
return;
}

if (isWidgetized() || self.isDashboard()) {
return;
}

$(domElem).width(maxTableWidth);

var parentDataTable = $(domElem).parent('.dataTable');
if (parentDataTable && parentDataTable.length) {
// makes sure dataTableWrapper and DataTable has same size => makes sure maxLabelWidth does not get
// applied in getLabelWidth() since they will have the same size.
parentDataTable.width(maxTableWidth);
}
}

function getLabelWidth(domElem, tableWidth, minLabelWidth, maxLabelWidth)
{
var labelWidth = minLabelWidth;
Expand All @@ -338,16 +366,14 @@ $.extend(DataTable.prototype, UIControl.prototype, {
labelWidth = tableWidth * 0.5;
}

var isWidgetized = -1 !== location.search.indexOf('module=Widgetize');

var innerWidth = 0;
var innerWrapper = domElem.find('.dataTableWrapper');
if (innerWrapper && innerWrapper.length) {
innerWidth = innerWrapper.width();
}

if (labelWidth > maxLabelWidth
&& !isWidgetized
&& !isWidgetized()
&& innerWidth !== domElem.width()
&& !self.isDashboard()) {
labelWidth = maxLabelWidth; // prevent for instance table in Actions-Pages is not too wide
Expand Down Expand Up @@ -405,7 +431,8 @@ $.extend(DataTable.prototype, UIControl.prototype, {
var minLabelWidth = 125;
var maxLabelWidth = 440;

var tableWidth = getTableWidth(domElem);
setMaxTableWidthIfNeeded(domElem, 1200);
var tableWidth = getTableWidth(domElem);
var labelColumnMinWidth = getLabelColumnMinWidth(domElem);
var labelColumnWidth = getLabelWidth(domElem, tableWidth, 125, 440);

Expand Down
4 changes: 2 additions & 2 deletions plugins/ZenMode/javascripts/zen-mode.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ $(document).ready(function () {
}

var addedElement = $('#topRightBar').append(
'<span class="topBarElem activateZenMode" piwik-zen-mode-switcher>'
' | <span class="topBarElem activateZenMode" piwik-zen-mode-switcher>'
+ '<img src="plugins/CoreHome/images/navigation_expand.png">'
+ ' </span>'
);
Expand Down Expand Up @@ -64,7 +64,7 @@ $(document).ready(function () {
toggleZenMode();
});

Mousetrap.bind('alt+s', function(event) {
Mousetrap.bind('alt+f', function(event) {
if (event.preventDefault) {
event.preventDefault();
} else {
Expand Down
2 changes: 1 addition & 1 deletion plugins/ZenMode/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"ZenMode": {
"SearchForAnything": "Search for anything",
"QuickAccessTitle": "Search for menu entries, reports and websites",
"HowToSearch": "To search for menu items, reports or websites use the search box on the top right or press 'alt+s'.",
"HowToSearch": "To search for menu items, reports or websites use the search box on the top right or press 'alt+f'.",
"HowToToggleZenMode": "To leave the zen mode click the arrow on the top right or press 'alt+z'.",
"Activated": "Zen mode activated"
}
Expand Down

0 comments on commit b02e74e

Please sign in to comment.