Skip to content

Commit 34efd4e

Browse files
committed
fix new chapter section overflow box
1 parent 37287ea commit 34efd4e

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

themes/cc-commoners/assets/js/cc-commoners-chapters.js

+13-13
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,24 @@ jQuery(document).ready(function($){
1212
}
1313

1414
var windowPosition = function(target) {
15-
console.log(target);
1615
var position = target.offset(),
1716
boundingBox = target[0].getBBox(),
18-
topY = position.top + boundingBox.height - 30,
19-
leftX = position.left + boundingBox.width - 30,
20-
mapOffset = $('#cc_worldmap').offset();
21-
22-
if ( leftX + info_box.width() > $(document).width() ) {
23-
leftX = leftX - info_box.width();
17+
topY = position.top + boundingBox.height,
18+
leftX = position.left + boundingBox.width,
19+
mapOffset = $('#cc_worldmap').offset(),
20+
mapWidth = $('#cc_worldmap').outerWidth();
21+
positionObj = { 'top': topY, 'left': leftX }
22+
23+
if ( leftX + info_box.outerWidth() > $(window).width() ) {
24+
valueX = $(window).outerWidth() - info_box.outerWidth() - boundingBox.width;
25+
positionObj.left = valueX;
2426
}
25-
if ( topY + info_box.height() > mapOffset.top + $('#cc_worldmap').height()) {
26-
topY = topY - info_box.height();
27+
if ( topY + info_box.outerHeight() > mapOffset.top + $('#cc_worldmap').outerHeight()) {
28+
topY = topY - boundingBox.height - info_box.outerHeight();
29+
positionObj.top = topY;
2730
}
2831

29-
info_box.css({
30-
'top': topY,
31-
'left': leftX
32-
});
32+
info_box.css(positionObj);
3333
}
3434
$.post(Ajax.url, { action: 'event-get-chapters'}, function(data){
3535
Country_data = data;

0 commit comments

Comments
 (0)