1 | <!DOCTYPE html>
|
---|
2 | <html id="story">
|
---|
3 | <head>
|
---|
4 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
---|
5 |
|
---|
6 | <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
|
---|
7 | <meta http-equiv="Pragma" content="no-cache" />
|
---|
8 | <meta http-equiv="Expires" content="0" />
|
---|
9 |
|
---|
10 | <!--
|
---|
11 | <meta name="viewport" content="width=device-width, initial-scale=1"/>
|
---|
12 | -->
|
---|
13 | <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
|
---|
14 | <meta http-equiv="X-UA-Compatible" content="IE=Edge, chrome=1"/>
|
---|
15 | <meta name="apple-mobile-web-app-capable" content="yes"/>
|
---|
16 |
|
---|
17 | <script src="css/source-sans-pro.js"></script>
|
---|
18 | <link href="css/styles.css" rel="stylesheet"/>
|
---|
19 | <link href="css/storystyle.css" rel="stylesheet"/>
|
---|
20 |
|
---|
21 | <link rel="stylesheet" href="lib-slider/css/jquery.mobile-1.3.0.css"/>
|
---|
22 | <link rel="stylesheet" href="lib-slider/css/jqm-demos.css"/>
|
---|
23 | <link rel="stylesheet" href="lib-slider/css/swipe-page.css"/>
|
---|
24 | <link rel="shortcut icon" href="lib-slider/nzflag-icon64-padded.png"/>
|
---|
25 |
|
---|
26 | <!-- jQuery -->
|
---|
27 | <script src="lib/jquery-1.11.1.min.js"></script>
|
---|
28 | <script src="lib/jquery.cookie.js"></script>
|
---|
29 |
|
---|
30 | <!-- page swipe -->
|
---|
31 | <script src="lib-slider/js/jquery.mobile.demos.js"></script>
|
---|
32 | <script src="lib-slider/js/jquery.mobile-1.3.0.js"></script>
|
---|
33 | <script src="lib-slider/js/swipe-page.js"></script>
|
---|
34 |
|
---|
35 | <!-- accordion bars -->
|
---|
36 | <link href="css/liteaccordion.css" rel="stylesheet" />
|
---|
37 | <script src="js/jquery.easing.1.3.js"></script>
|
---|
38 | <script src="js/liteaccordion-with-resize.jquery.js"></script>
|
---|
39 |
|
---|
40 | <!-- canvg library -->
|
---|
41 | <script type="text/javascript" src="lib/canvg/rgbcolor.js"></script>
|
---|
42 | <script type="text/javascript" src="lib/canvg/StackBlur.js"></script>
|
---|
43 | <script type="text/javascript" src="lib/canvg/canvg.js"></script>
|
---|
44 |
|
---|
45 | <!-- spectrum for colour palette -->
|
---|
46 | <!-- For documentation see https://bgrins.github.io/spectrum -->
|
---|
47 | <script src='bgrins-spectrum/spectrum.js'></script>
|
---|
48 | <link rel='stylesheet' href='bgrins-spectrum/spectrum.css' />
|
---|
49 |
|
---|
50 | <!-- css for choose-palette -->
|
---|
51 | <style>
|
---|
52 | .ui-slider-track {
|
---|
53 | background-color: #ECECEC;
|
---|
54 | }
|
---|
55 | .ui-slider-handle {
|
---|
56 | background-color: #a05a2c; /* used to be #E7924B; */
|
---|
57 | }
|
---|
58 | </style>
|
---|
59 |
|
---|
60 | <script>
|
---|
61 | // Flag settings - used to initialise the svg canvas to the user's preferences
|
---|
62 | var flagCanvasSettings = { backgroundColor: "#000066", width: 800, height: 400 };
|
---|
63 |
|
---|
64 | </script>
|
---|
65 |
|
---|
66 | <title>Canvas Size</title>
|
---|
67 |
|
---|
68 | <script>
|
---|
69 |
|
---|
70 | // Variable for the currently selected flag ratio
|
---|
71 | var currentRatio = null;
|
---|
72 |
|
---|
73 | $(function() {
|
---|
74 | $.getJSON( "../similarity-2d/flag-aspect-ratios-json.jsp", function( data ) {
|
---|
75 |
|
---|
76 |
|
---|
77 | //var scale_to_y_dim = 130;
|
---|
78 |
|
---|
79 | // express scale_to_y_dim to use relative to height of window
|
---|
80 |
|
---|
81 | var la_y_dim = $(window).height() - $('#aspect-ratio-div').position().top;
|
---|
82 | var scale_to_y_dim = la_y_dim/4;
|
---|
83 |
|
---|
84 | //alert("scale_to_y_dim = " + scale_to_y_dim);
|
---|
85 |
|
---|
86 | var items = [];
|
---|
87 |
|
---|
88 | var max_ratio = 0;
|
---|
89 | $.each( data, function( key, ratio_table ) {
|
---|
90 | var ratio_array = key.split(":");
|
---|
91 | var ratio_x = ratio_array[0];
|
---|
92 | var ratio_y = ratio_array[1];
|
---|
93 | var ratio = ratio_y / ratio_x;
|
---|
94 |
|
---|
95 | if (ratio > max_ratio) {
|
---|
96 | max_ratio = ratio;
|
---|
97 | }
|
---|
98 | });
|
---|
99 |
|
---|
100 | $.each( data, function( key, ratio_table ) {
|
---|
101 | var freq = ratio_table.freq;
|
---|
102 | var ratio_array = key.split(":");
|
---|
103 | var ratio_x = ratio_array[0];
|
---|
104 | var ratio_y = ratio_array[1];
|
---|
105 | var ratio = ratio_y / ratio_x;
|
---|
106 |
|
---|
107 | var ratioScale = max_ratio/ratio;
|
---|
108 |
|
---|
109 | var x_dim = Math.round(scale_to_y_dim * ratioScale);
|
---|
110 | var y_dim = scale_to_y_dim;
|
---|
111 |
|
---|
112 | var innertext = "<div style='font-size: 180%;'>"+freq + " countries, " + key + "</div>";
|
---|
113 |
|
---|
114 | var flags = [];
|
---|
115 |
|
---|
116 | var nz_prioritized_flags = ratio_table.flags.sort();
|
---|
117 |
|
---|
118 | // Promote NZ flag to start of array, but otherwise keep sorted
|
---|
119 | var p = nz_prioritized_flags.length-1;
|
---|
120 | var found_nz = false;
|
---|
121 |
|
---|
122 | while (p>0) {
|
---|
123 | var curr;
|
---|
124 | var curr_title;
|
---|
125 |
|
---|
126 | if (!found_nz) {
|
---|
127 | curr = ratio_table.flags[p];
|
---|
128 | curr_title = curr.replace(/^.*\//,"").replace(/\.(.*?)$/,"");
|
---|
129 | }
|
---|
130 |
|
---|
131 | if (curr_title == "nz") {
|
---|
132 | found_nz = true;
|
---|
133 |
|
---|
134 | // swap with adjacent cell
|
---|
135 | var tmp_m1 = nz_prioritized_flags[p-1];
|
---|
136 | nz_prioritized_flags[p-1] = curr;
|
---|
137 | nz_prioritized_flags[p] = tmp_m1;
|
---|
138 | }
|
---|
139 | p--;
|
---|
140 | }
|
---|
141 |
|
---|
142 | $.each(nz_prioritized_flags, function(index, flag_filename) {
|
---|
143 | var title = flag_filename.replace(/^.*\//,"").replace(/\.(.*?)$/,"");
|
---|
144 |
|
---|
145 | flags.push("<img src='../similarity-2d/"+flag_filename+"' style='height: 70px; padding: 3px; ' title='" + title.toUpperCase() + "'/>");
|
---|
146 | });
|
---|
147 |
|
---|
148 | innertext += flags.join("");
|
---|
149 |
|
---|
150 | var ratio_id = "ratio-" + key;
|
---|
151 | if (found_nz) {
|
---|
152 | currentRatio = ratio_id;
|
---|
153 | }
|
---|
154 |
|
---|
155 | var id = " id='" + ratio_id + "'";
|
---|
156 |
|
---|
157 | var style = "style='width:" + x_dim + "px; height:" + y_dim + "px;";
|
---|
158 | if (found_nz) {
|
---|
159 | style += "border-color:white; border-width:4px;"
|
---|
160 | }
|
---|
161 | //if (ratio_table.flags.length>4) {
|
---|
162 | style += " overflow-y:scroll;";
|
---|
163 | //}
|
---|
164 | style += "'";
|
---|
165 |
|
---|
166 | var onclick = " onclick='updateCanvasDimensions("+ratio_y + "," + ratio_x + ")'";
|
---|
167 |
|
---|
168 | items.push( "<div class='ratioDiv'" + id + style+ onclick + ">"+ innertext + "</div>" );
|
---|
169 |
|
---|
170 | });
|
---|
171 |
|
---|
172 | $('#aspect-ratio-div').append("<div class='centredDiv' style='width: 100%'>"+items.join("\n")+"</div>");
|
---|
173 |
|
---|
174 |
|
---|
175 | // now change the flag tooltip labels into their country names
|
---|
176 | $.getJSON( "../similarity-2d/iso-3166-keyed-by-alpha-2-countrycodes.json", function( data ) {
|
---|
177 |
|
---|
178 | });
|
---|
179 |
|
---|
180 | });
|
---|
181 | });
|
---|
182 | </script>
|
---|
183 | </head>
|
---|
184 |
|
---|
185 | <body>
|
---|
186 | <div data-role="page" id="choose-canvas-page"
|
---|
187 | class="demo-page"
|
---|
188 | data-dom-cache="true"
|
---|
189 | data-next="choose-palette">
|
---|
190 |
|
---|
191 | <div data-role="content">
|
---|
192 |
|
---|
193 | <div data-role="controlgroup" class="control" data-mini="true">
|
---|
194 | <a href="#" class="next right-button res-fwd" style="right:1%;"></a>
|
---|
195 | <!--
|
---|
196 | <a href="#" class="prev left-button gen-back" style="left:1%;"></a>
|
---|
197 | -->
|
---|
198 | </div>
|
---|
199 |
|
---|
200 | <a target="_parent" href="../index.html" class="back-button back-left"></a>
|
---|
201 |
|
---|
202 | <div class="story-page">
|
---|
203 |
|
---|
204 | <!-- put custom content here -->
|
---|
205 | <span class="left story-icon idea" ></span>
|
---|
206 | <h2>Canvas Size</h2>
|
---|
207 |
|
---|
208 | <div class="dialog" id="dialog" title="Flat Aspect Ratio Selection Panel" widthXX="800px">
|
---|
209 | <br><br>
|
---|
210 | <h2>Please choose from the following aspect ratios.</h2>
|
---|
211 | <p>
|
---|
212 | Once chosen, swipe the page or click/press on the right arrow to go onto the next step.
|
---|
213 | </p>
|
---|
214 |
|
---|
215 | <div id="aspect-ratio-div">
|
---|
216 | </div>
|
---|
217 |
|
---|
218 |
|
---|
219 | <!--
|
---|
220 | <div class="centredDiv">
|
---|
221 | <div class="ratioDiv flagHover" id="ratio23" onclick="updateCanvasDimensions(2, 3)" title="2:3"></div>
|
---|
222 | <div class="ratioDiv" style="border-width:2px;" id="ratio12" onclick="updateCanvasDimensions(1, 2)" title="1:2"></div>
|
---|
223 | <div class="ratioDiv" id="ratio35" onclick="updateCanvasDimensions(3, 5)" title="3:5"></div>
|
---|
224 | <div style="clear: both"></div>
|
---|
225 | </div>
|
---|
226 | <p class="optionline">2:3 1:2 3:5</p><br>
|
---|
227 |
|
---|
228 | <div class="centredDiv">
|
---|
229 | <div class="ratioDiv" id="ratio1019" onclick="updateCanvasDimensions(10, 19)" title="10:19"></div>
|
---|
230 | <div class="ratioDiv" id="ratio58" onclick="updateCanvasDimensions(5, 8)" title="5:8"></div>
|
---|
231 | <div class="ratioDiv" id="ratio811" onclick="updateCanvasDimensions(8, 11)" title="8:11"></div>
|
---|
232 | <div style="clear: both"></div>
|
---|
233 | </div>
|
---|
234 | <p class="optionline">10:19 5:8 8:11</p>
|
---|
235 | -->
|
---|
236 | </div>
|
---|
237 |
|
---|
238 | <script>
|
---|
239 |
|
---|
240 | function updateCanvasDimensions(height, width) {
|
---|
241 |
|
---|
242 | // Show feedback by highlighting the chosen square
|
---|
243 | document.getElementById(currentRatio).style.borderColor = 'black';
|
---|
244 | document.getElementById(currentRatio).style.borderWidth = '1px';
|
---|
245 | currentRatio = "ratio-" + width + ":" + height;
|
---|
246 | document.getElementById(currentRatio).style.borderColor = 'white';
|
---|
247 | document.getElementById(currentRatio).style.borderWidth = '4px';
|
---|
248 |
|
---|
249 | // Changing the value of sizeConstant will change the
|
---|
250 | // size of the svg canvas without affecting the
|
---|
251 | // width/height ratios
|
---|
252 |
|
---|
253 | var sizeConstant = 400;
|
---|
254 |
|
---|
255 | var h = sizeConstant;
|
---|
256 | var w = (sizeConstant / height) * width;
|
---|
257 |
|
---|
258 | if (typeof flagCanvasSettings !== 'undefined') {
|
---|
259 | flagCanvasSettings.width = w;
|
---|
260 | flagCanvasSettings.height = h;
|
---|
261 | }
|
---|
262 | }
|
---|
263 |
|
---|
264 |
|
---|
265 | </script>
|
---|
266 |
|
---|
267 | <!-- end of putting custom content -->
|
---|
268 |
|
---|
269 | </div> <!-- end story-page-->
|
---|
270 |
|
---|
271 | </div><!-- /content -->
|
---|
272 |
|
---|
273 | <!-- make persistent?
|
---|
274 | <div data-role="footer" style="width:100%;">
|
---|
275 | COSI: Centre of Open Source Innovation @ The University of Waikato.
|
---|
276 | </div>
|
---|
277 | -->
|
---|
278 |
|
---|
279 | </div><!-- /page -->
|
---|
280 |
|
---|
281 | </body>
|
---|
282 | </html>
|
---|