@@ -16,21 +16,21 @@ var d3Graphs = {
16
16
barWidth : 14 ,
17
17
barGraphTopPadding : 20 ,
18
18
barGraphBottomPadding : 50 ,
19
- histogramWidth : 780 ,
19
+ histogramWidth : 686 ,
20
20
histogramHeight : 160 ,
21
21
histogramLeftPadding :31 ,
22
22
histogramRightPadding : 31 ,
23
23
histogramVertPadding :20 ,
24
- barGraphSVG : d3 . select ( "body " ) . append ( "svg" ) ,
24
+ barGraphSVG : d3 . select ( "#wrapper " ) . append ( "svg" ) ,
25
25
histogramSVG : null ,
26
26
histogramYScale : null ,
27
27
histogramXScale : null ,
28
28
cumImportY : 0 , cumExportY : 0 ,
29
29
cumImportLblY : 0 , cumExportLblY : 0 ,
30
30
inited : false ,
31
31
histogramOpen : false ,
32
- handleLeftOffset : 14 ,
33
- handleInterval : 40 ,
32
+ handleLeftOffset : 12 ,
33
+ handleInterval : 35 ,
34
34
windowResizeTimeout : - 1 ,
35
35
histogramImports : null ,
36
36
histogramExports : null ,
@@ -41,7 +41,7 @@ var d3Graphs = {
41
41
42
42
43
43
setCountry : function ( country ) {
44
- $ ( "#hudHeader .countryTextInput" ) . val ( country ) ;
44
+ $ ( "#hudButtons .countryTextInput" ) . val ( country ) ;
45
45
d3Graphs . updateViz ( ) ;
46
46
} ,
47
47
initGraphs : function ( ) {
@@ -52,22 +52,22 @@ var d3Graphs = {
52
52
showHud : function ( ) {
53
53
if ( this . inited ) return ;
54
54
this . inited = true ;
55
- $ ( "#hudHeader" ) . show ( ) ;
56
- d3Graphs . positionHistory ( ) ;
55
+ d3Graphs . windowResize ( ) ;
56
+ $ ( "#hudHeader, #hudButtons" ) . show ( ) ;
57
57
$ ( "#history" ) . show ( ) ;
58
58
$ ( "#graphIcon" ) . show ( ) ;
59
59
$ ( "#importExportBtns" ) . show ( ) ;
60
60
$ ( "#graphIcon" ) . click ( d3Graphs . graphIconClick ) ;
61
61
$ ( "#history .close" ) . click ( d3Graphs . closeHistogram ) ;
62
62
$ ( "#history ul li" ) . click ( d3Graphs . clickTimeline ) ;
63
63
$ ( "#handle" ) . draggable ( { axis : 'x' , containment : "parent" , grid :[ this . handleInterval , this . handleInterval ] , stop : d3Graphs . dropHandle , drag : d3Graphs . dropHandle } ) ;
64
- $ ( "#hudHeader .searchBtn" ) . click ( d3Graphs . updateViz ) ;
64
+ $ ( "#hudButtons .searchBtn" ) . click ( d3Graphs . updateViz ) ;
65
65
$ ( "#importExportBtns .imex>div" ) . not ( ".label" ) . click ( d3Graphs . importExportBtnClick ) ;
66
66
$ ( "#importExportBtns .imex .label" ) . click ( d3Graphs . importExportLabelClick ) ;
67
- $ ( "#hudHeader .countryTextInput" ) . autocomplete ( { source :selectableCountries , autoFocus : true } ) ;
68
- $ ( "#hudHeader .countryTextInput" ) . keyup ( d3Graphs . countryKeyUp ) ;
69
- $ ( "#hudHeader .countryTextInput" ) . focus ( d3Graphs . countryFocus ) ;
70
- $ ( "#hudHeader .aboutBtn" ) . click ( d3Graphs . toggleAboutBox ) ;
67
+ $ ( "#hudButtons .countryTextInput" ) . autocomplete ( { source :selectableCountries , autoFocus : true } ) ;
68
+ $ ( "#hudButtons .countryTextInput" ) . keyup ( d3Graphs . countryKeyUp ) ;
69
+ $ ( "#hudButtons .countryTextInput" ) . focus ( d3Graphs . countryFocus ) ;
70
+ $ ( "#hudButtons .aboutBtn" ) . click ( d3Graphs . toggleAboutBox ) ;
71
71
$ ( document ) . on ( "click" , ".ui-autocomplete li" , d3Graphs . menuItemClick ) ;
72
72
$ ( window ) . resize ( d3Graphs . windowResizeCB ) ;
73
73
$ ( ".zoomBtn" ) . mousedown ( d3Graphs . zoomBtnClick ) ;
@@ -109,20 +109,42 @@ var d3Graphs = {
109
109
} ,
110
110
windowResizeCB :function ( ) {
111
111
clearTimeout ( d3Graphs . windowResizeTimeout ) ;
112
- d3Graphs . windowResizeTimeout = setTimeout ( d3Graphs . positionHistory , 250 ) ;
112
+ d3Graphs . windowResizeTimeout = setTimeout ( d3Graphs . windowResize , 50 ) ;
113
113
} ,
114
- positionHistory : function ( ) {
114
+ windowResize : function ( ) {
115
+ var windowWidth = $ ( window ) . width ( ) ;
116
+ var windowHeight = $ ( window ) . height ( ) ;
117
+ d3Graphs . positionHistory ( windowWidth ) ;
118
+ var minWidth = 1280 ;
119
+ var w = windowWidth < minWidth ? minWidth : windowWidth ;
120
+ var hudButtonWidth = 489 ;
121
+ $ ( '#hudButtons' ) . css ( 'left' , w - hudButtonWidth - 20 ) ;
122
+ var importExportButtonWidth = $ ( "#importExportBtns" ) . width ( ) ;
123
+ $ ( "#importExportBtns" ) . css ( 'left' , w - importExportButtonWidth - 20 ) ;
124
+ /*
125
+ var hudHeaderLeft = $("#hudHeader").css('left');
126
+ hudHeaderLeft = hudHeaderLeft.substr(0,hudHeaderLeft.length-2)
127
+ console.log(hudHeaderLeft);
128
+ var hudPaddingRight = 30;
129
+ $("#hudHeader").width(w-hudHeaderLeft - hudPaddingRight);
130
+ */
131
+ } ,
132
+ positionHistory : function ( windowWidth ) {
115
133
var graphIconPadding = 20 ;
116
134
var historyWidth = $ ( "#history" ) . width ( ) ;
117
135
var totalWidth = historyWidth + $ ( "#graphIcon" ) . width ( ) + graphIconPadding ;
118
- var windowWidth = $ ( window ) . width ( ) ;
136
+ // var windowWidth = $(window).width();
119
137
var historyLeftPos = ( windowWidth - totalWidth ) / 2.0 ;
138
+ var minLeftPos = 280 ;
139
+ if ( historyLeftPos < minLeftPos ) {
140
+ historyLeftPos = minLeftPos ;
141
+ }
120
142
$ ( "#history" ) . css ( 'left' , historyLeftPos + "px" ) ;
121
143
$ ( "#graphIcon" ) . css ( 'left' , historyLeftPos + historyWidth + graphIconPadding + 'px' ) ;
122
144
} ,
123
145
countryFocus :function ( event ) {
124
146
//console.log("focus");
125
- setTimeout ( function ( ) { $ ( '#hudHeader .countryTextInput' ) . select ( ) } , 50 ) ;
147
+ setTimeout ( function ( ) { $ ( '#hudButtons .countryTextInput' ) . select ( ) } , 50 ) ;
126
148
} ,
127
149
menuItemClick :function ( event ) {
128
150
d3Graphs . updateViz ( ) ;
@@ -140,7 +162,7 @@ var d3Graphs = {
140
162
yearOffset /= d3Graphs . handleInterval ;
141
163
var year = yearOffset + 1992 ;
142
164
143
- var country = $ ( "#hudHeader .countryTextInput" ) . val ( ) . toUpperCase ( ) ;
165
+ var country = $ ( "#hudButtons .countryTextInput" ) . val ( ) . toUpperCase ( ) ;
144
166
if ( typeof countryData [ country ] == 'undefined' ) {
145
167
return ;
146
168
}
0 commit comments