@@ -12,24 +12,24 @@ jQuery(document).ready(function($){
12
12
}
13
13
14
14
var windowPosition = function ( target ) {
15
- console . log ( target ) ;
16
15
var position = target . offset ( ) ,
17
16
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 ;
24
26
}
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 ;
27
30
}
28
31
29
- info_box . css ( {
30
- 'top' : topY ,
31
- 'left' : leftX
32
- } ) ;
32
+ info_box . css ( positionObj ) ;
33
33
}
34
34
$ . post ( Ajax . url , { action : 'event-get-chapters' } , function ( data ) {
35
35
Country_data = data ;
0 commit comments