source: other-projects/nz-flag-design/trunk/main-form/iterative-design.html@ 29631

Last change on this file since 29631 was 29631, checked in by davidb, 9 years ago

Folder for our changes

  • Property svn:executable set to *
File size: 6.1 KB
Line 
1<!DOCTYPE html>
2<html id="story">
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
5 <meta name="viewport" content="width=device-width, initial-scale=1"/>
6
7 <title>Iterative Design</title>
8
9 </head>
10
11 <body>
12 <div data-role="page" id="iterative-design-page"
13 class="demo-page"
14 data-dom-cache="true"
15 data-prev="choose-palette"
16 data-next="design-info">
17
18 <div data-role="content">
19
20 <div data-role="controlgroup" class="control" data-mini="true">
21 <a href="#" class="next right-button test-fwd" style="right:1%;"></a>
22 <a href="#" class="prev left-button idea-back" style="left:1%;"></a>
23 </div>
24
25 <div class="story-page">
26
27 <!-- put custom content here -->
28 <span class="left story-icon research" ></span>
29 <h2 id="iterative-design-header">Iterative Design</h2>
30
31 <div>
32 <div id="side-by-side">
33 <ol>
34
35 <li>
36 <h2><span>2D Design</span></h2>
37 <div id="design-2d-div" >
38
39 <iframe style="width: 100%; height: 100%"
40 id="design-2d-iframe" ></iframe>
41 </div>
42 </li>
43
44 <li>
45 <h2><span title="Click to Open/Close">Flag Similarity</span></h2>
46
47 <div id="similarity-2d-div">
48 <iframe src="../similarity-2d/display-flags.jsp"
49 style="width: 100%; height: 100%"
50 id="similarity-2d-iframe" ></iframe>
51 </div>
52
53 </li>
54 <li>
55 <h2><span title="Click to Open/Close">Render 3D</span></h2>
56 <div id="render-3d-div">
57 <iframe src="../render-3d/flag.html"
58 style="width: 100%; height: 100%; overflow: hidden;"
59 id="render-3d-iframe" ></iframe>
60 </div>
61 </li>
62
63 </ol>
64 </div>
65 </div>
66
67 <!-- end of putting custom content -->
68
69 </div> <!-- end story-page-->
70 </div><!-- /content -->
71
72 <script>
73
74
75 var activatedAccordion = false;
76 var activatedSVGEditorFrame = false;
77
78
79 function savePNGAsFile(imgType, quality) {
80
81 var design_frame = document.getElementById('design-2d-iframe');
82 var svgCanvas = design_frame.contentWindow.svgCanvas;
83 var svgedit = design_frame.contentWindow.svgedit;
84
85 var mimeType = 'image/' + imgType.toLowerCase();
86 var svg_str = svgCanvas.svgCanvasToString();
87
88
89 var type = imgType || 'PNG';
90 if (!$('#export_canvas').length) {
91 $('<canvas>', {id: 'export_canvas'}).hide().appendTo('body');
92 }
93 var c = $('#export_canvas')[0];
94 c.width = svgCanvas.contentW;
95 c.height = svgCanvas.contentH;
96
97 canvg(c, svg_str, {renderCallback: function() {
98 var dataURLType = (type === 'ICO' ? 'BMP' : type).toLowerCase();
99 var datauri = quality ? c.toDataURL('image/' + dataURLType, quality) : c.toDataURL('image/' + dataURLType);
100
101 // Look up jsession id; if not present fall back to use a timestamp
102 var jsession_id = $.cookie('JSESSIONID') || new Date().getTime();
103 console.log("jsession id = " + jsession_id);
104 var imageFilename = "flag-" + jsession_id + ".png";
105
106 $.ajax({
107 type: "POST",
108 url: "../design-2d/image-data-to-file.jsp",
109 data: { imageData: datauri, imageFilename: imageFilename },
110 success: function() {
111 console.log("Exported PNG data to file ");
112 var render_frame = document.getElementById('render-3d-iframe');
113 // trigger a reload in the 3D Flag Renderer
114 render_frame.contentWindow.createFlag(imageFilename);
115 }
116 });
117 }
118 });
119
120 }
121
122 function exportPNG() {
123 var design_frame = document.getElementById('design-2d-iframe')
124 var str = design_frame.contentWindow.svgEditor.uiStrings.notification.loadingImage;
125
126 var exportWindow = window.open(
127 'data:text/html;charset=utf-8,' + encodeURIComponent('<title>' + str + '</title><h1>' + str + '</h1>'),
128 'svg-edit-exportWindow'
129 );
130
131 design_frame.contentWindow.svgCanvas.rasterExport("PNG", null, exportWindow.name);
132
133 //svgCanvas.rasterExport('PNG', null, exportWindow.name);
134 }
135
136
137 function activateAccordion() {
138
139 var la_x_dim = $(window).width() * 0.70;
140 var la_y_dim = $(window).height() * 0.67;
141
142
143 $('#side-by-side').show();
144
145 $('#side-by-side')
146 .liteAccordion(
147 { theme : 'stitch', // 'light',
148 rounded : true,
149 //responsive : true,
150 containerWidth : la_x_dim,
151 containerHeight : la_y_dim,
152 onTriggerSlide : function() {
153 console.log("onTriggerSlide: id = " + this[0].id);
154 if (this[0].id == "render-3d-div") {
155 console.log("Triggering SVG-Editor exportPNG()");
156 savePNGAsFile("PNG",null);
157 }
158 }
159 }
160 );
161 }
162
163 function activateSVGEditor() {
164 console.log("activateSVGEditor()");
165 $('#design-2d-iframe').attr("src","svg-edit-trunk/editor/svg-editor.html");
166 }
167
168 $(document).on("pageload",function(event,data){
169 console.log( "Iterative Design Page: jquerymobile pageload()" );
170 if (!activatedAccordion) {
171 activateAccordion();
172 activatedAccordion = true;
173 }
174 });
175
176 $(window).resize(function() {
177 var la_x_dim = $(window).width() * 0.70;
178 var la_y_dim = $(window).height() * 0.67;
179
180 $('#side-by-side')
181 .liteAccordion('resize',
182 { containerWidth : la_x_dim,
183 containerHeight : la_y_dim
184 }
185 );
186
187
188 });
189
190 $(document).on("pagebeforeshow",function(event,data){
191 var active_page = $.mobile.activePage.attr("id");
192 console.log("Event: pagebeforeshow() for page " + active_page);
193
194 if (!activatedSVGEditorFrame && (active_page == "iterative-design-page")) {
195 activateSVGEditor();
196 activatedSVGEditorFrame = true;
197 }
198
199 });
200
201 </script>
202
203
204 </div><!-- /page -->
205
206
207 </body>
208</html>
Note: See TracBrowser for help on using the repository browser.