[Toolbar] Handle info position via javascript

Place info div to not float out of the window
This commit is contained in:
Stefano Sala 2014-11-29 11:46:43 +01:00
parent 7a8582e1f6
commit 23c0ddca39
2 changed files with 20 additions and 4 deletions

View File

@ -139,10 +139,6 @@
border-radius: 4px 4px 0 0;
}
.sf-toolbarreset > div:last-of-type .sf-toolbar-info {
right: -1px;
}
.sf-toolbar-block .sf-toolbar-info:empty {
visibility: hidden;
}

View File

@ -31,6 +31,26 @@
}
Sfjs.renderAjaxRequests();
/* Handle toolbar-info position */
var toolbarBlocks = document.getElementsByClassName('sf-toolbar-block');
for (var i = 0; i < toolbarBlocks.length; i += 1) {
toolbarBlocks[i].onmouseover = function () {
var toolbarInfo = this.getElementsByClassName('sf-toolbar-info')[0];
var pageWidth = document.body.clientWidth;
var elementWidth = toolbarInfo.offsetWidth;
var leftValue = (elementWidth + this.offsetLeft) - pageWidth;
var rightValue = (elementWidth + (pageWidth - this.offsetLeft)) - pageWidth;
if (leftValue > 0 && rightValue > 0) {
toolbarInfo.style.right = (rightValue * -1) + 'px';
} else if (leftValue < 0) {
toolbarInfo.style.left = 0;
} else {
toolbarInfo.style.right = '-1px';
}
};
}
},
function(xhr) {
if (xhr.status !== 0) {