Browse Source

Fix compile issues for missing/brokebn imports

master
Lewis Hemens 1 year ago
parent
commit
c50eaf5daa
4 changed files with 496 additions and 462 deletions
  1. 0
    0
      closure-compiler.jar
  2. 398
    373
      js-compiled.js
  3. 90
    80
      js-lib/controller.js
  4. 8
    9
      js-lib/draw/index.js

+ 0
- 0
closure-compiler.jar View File


+ 398
- 373
js-compiled.js
File diff suppressed because it is too large
View File


+ 90
- 80
js-lib/controller.js View File

@@ -1,26 +1,17 @@
1
-import * as c from './constants';
2
-import Vector from './vector';
3
-import View from './view';
4
-import State from './state';
5
-import {
6
-  DrawFunction,
7
-  DrawBox,
8
-  DrawLine,
9
-  DrawFreeform,
10
-  DrawErase,
11
-  DrawMove,
12
-  DrawText,
13
-  DrawSelect,
14
-} from './draw/index';
15
-
1
+import * as c from "./constants";
2
+import Vector from "./vector";
3
+import View from "./view";
4
+import State from "./state";
5
+import { DrawFunction, DrawBox, DrawLine, DrawFreeform, DrawErase, DrawMove, DrawText, DrawSelect } from "./draw/index";
6
+import DrawFunction from "./function";
16 7
 
17 8
 /**
18 9
  * Different modes of control.
19 10
  */
20 11
 const Mode = {
21
-    NONE: 0,
22
-    DRAG: 1,
23
-    DRAW: 2
12
+  NONE: 0,
13
+  DRAG: 1,
14
+  DRAW: 2
24 15
 };
25 16
 
26 17
 /**
@@ -86,10 +77,7 @@ export default class Controller {
86 77
 
87 78
     // Drag in progress, update the view origin.
88 79
     if (this.mode == Mode.DRAG) {
89
-      this.view.setOffset(this.dragOriginCell.add(
90
-          this.dragOrigin
91
-              .subtract(position)
92
-              .scale(1 / this.view.zoom)));
80
+      this.view.setOffset(this.dragOriginCell.add(this.dragOrigin.subtract(position).scale(1 / this.view.zoom)));
93 81
     }
94 82
     this.lastMoveCell = moveCell;
95 83
   }
@@ -112,41 +100,42 @@ export default class Controller {
112 100
    * Installs input bindings for common use cases devices.
113 101
    */
114 102
   installBindings() {
115
-    $(window).resize(e => { this.view.resizeCanvas() });
103
+    $(window).resize(e => {
104
+      this.view.resizeCanvas();
105
+    });
116 106
 
117
-    $('#draw-tools > button.tool').click(e => {
118
-      $('#text-tool-widget').hide(0);
107
+    $("#draw-tools > button.tool").click(e => {
108
+      $("#text-tool-widget").hide(0);
119 109
       this.handleDrawButton(e.target.id);
120 110
     });
121 111
 
122
-    $('#file-tools > button.tool').click(e => {
112
+    $("#file-tools > button.tool").click(e => {
123 113
       this.handleFileButton(e.target.id);
124 114
     });
125 115
 
126
-    $('button.close-dialog-button').click(e => {
127
-      $('.dialog').removeClass('visible');
116
+    $("button.close-dialog-button").click(e => {
117
+      $(".dialog").removeClass("visible");
128 118
     });
129 119
 
130
-    $('#import-submit-button').click(e => {
120
+    $("#import-submit-button").click(e => {
131 121
       this.state.clear();
132 122
       this.state.fromText(
133
-          /** @type {string} */
134
-          ($('#import-area').val()),
135
-          this.view.screenToCell(new Vector(
136
-              this.view.canvas.width / 2,
137
-              this.view.canvas.height / 2)));
123
+        /** @type {string} */
124
+        ($("#import-area").val()),
125
+        this.view.screenToCell(new Vector(this.view.canvas.width / 2, this.view.canvas.height / 2))
126
+      );
138 127
       this.state.commitDraw();
139
-      $('#import-area').val('');
140
-      $('.dialog').removeClass('visible');
128
+      $("#import-area").val("");
129
+      $(".dialog").removeClass("visible");
141 130
     });
142 131
 
143
-    $('#use-lines-button').click(e => {
144
-      $('.dialog').removeClass('visible');
132
+    $("#use-lines-button").click(e => {
133
+      $(".dialog").removeClass("visible");
145 134
       this.view.setUseLines(true);
146 135
     });
147 136
 
148
-    $('#use-ascii-button').click(e => {
149
-      $('.dialog').removeClass('visible');
137
+    $("#use-ascii-button").click(e => {
138
+      $(".dialog").removeClass("visible");
150 139
       this.view.setUseLines(false);
151 140
     });
152 141
 
@@ -159,14 +148,14 @@ export default class Controller {
159 148
     });
160 149
 
161 150
     // Bit of a hack, just triggers the text tool to get a new value.
162
-    $('#text-tool-input, #freeform-tool-input').keyup(() => {
163
-        this.drawFunction.handleKey('');
151
+    $("#text-tool-input, #freeform-tool-input").keyup(() => {
152
+      this.drawFunction.handleKey("");
164 153
     });
165
-    $('#text-tool-input, #freeform-tool-input').change(() => {
166
-        this.drawFunction.handleKey('');
154
+    $("#text-tool-input, #freeform-tool-input").change(() => {
155
+      this.drawFunction.handleKey("");
167 156
     });
168
-    $('#text-tool-close').click(() => {
169
-      $('#text-tool-widget').hide();
157
+    $("#text-tool-close").click(() => {
158
+      $("#text-tool-widget").hide();
170 159
       this.state.commitDraw();
171 160
     });
172 161
   }
@@ -176,33 +165,33 @@ export default class Controller {
176 165
    * @param {string} id The ID of the element clicked.
177 166
    */
178 167
   handleDrawButton(id) {
179
-    $('#draw-tools > button.tool').removeClass('active');
180
-    $('#' + id).toggleClass('active');
181
-    $('.dialog').removeClass('visible');
168
+    $("#draw-tools > button.tool").removeClass("active");
169
+    $("#" + id).toggleClass("active");
170
+    $(".dialog").removeClass("visible");
182 171
 
183 172
     // Install the right draw tool based on button pressed.
184
-    if (id == 'box-button') {
173
+    if (id == "box-button") {
185 174
       this.drawFunction = new DrawBox(this.state);
186 175
     }
187
-    if (id == 'line-button') {
176
+    if (id == "line-button") {
188 177
       this.drawFunction = new DrawLine(this.state, false);
189 178
     }
190
-    if (id == 'arrow-button') {
179
+    if (id == "arrow-button") {
191 180
       this.drawFunction = new DrawLine(this.state, true);
192 181
     }
193
-    if (id == 'freeform-button') {
182
+    if (id == "freeform-button") {
194 183
       this.drawFunction = new DrawFreeform(this.state, "X");
195 184
     }
196
-    if (id == 'erase-button') {
185
+    if (id == "erase-button") {
197 186
       this.drawFunction = new DrawErase(this.state);
198 187
     }
199
-    if (id == 'move-button') {
188
+    if (id == "move-button") {
200 189
       this.drawFunction = new DrawMove(this.state);
201 190
     }
202
-    if (id == 'text-button') {
191
+    if (id == "text-button") {
203 192
       this.drawFunction = new DrawText(this.state, this.view);
204 193
     }
205
-    if (id == 'select-button') {
194
+    if (id == "select-button") {
206 195
       this.drawFunction = new DrawSelect(this.state);
207 196
     }
208 197
     this.state.commitDraw();
@@ -214,25 +203,25 @@ export default class Controller {
214 203
    * @param {string} id The ID of the element clicked.
215 204
    */
216 205
   handleFileButton(id) {
217
-    $('.dialog').removeClass('visible');
218
-    $('#' + id + '-dialog').toggleClass('visible');
206
+    $(".dialog").removeClass("visible");
207
+    $("#" + id + "-dialog").toggleClass("visible");
219 208
 
220
-    if (id == 'import-button') {
221
-      $('#import-area').val('');
222
-      $('#import-area').focus();
209
+    if (id == "import-button") {
210
+      $("#import-area").val("");
211
+      $("#import-area").focus();
223 212
     }
224 213
 
225
-    if (id == 'export-button') {
226
-      $('#export-area').val(this.state.outputText());
227
-      $('#export-area').select();
214
+    if (id == "export-button") {
215
+      $("#export-area").val(this.state.outputText());
216
+      $("#export-area").select();
228 217
     }
229
-    if (id == 'clear-button') {
218
+    if (id == "clear-button") {
230 219
       this.state.clear();
231 220
     }
232
-    if (id == 'undo-button') {
221
+    if (id == "undo-button") {
233 222
       this.state.undo();
234 223
     }
235
-    if (id == 'redo-button') {
224
+    if (id == "redo-button") {
236 225
       this.state.redo();
237 226
     }
238 227
   }
@@ -256,19 +245,41 @@ export default class Controller {
256 245
     var specialKeyCode = null;
257 246
 
258 247
     if (event.ctrlKey || event.metaKey) {
259
-      if (event.keyCode == 67) { specialKeyCode = c.KEY_COPY; }
260
-      if (event.keyCode == 86) { specialKeyCode = c.KEY_PASTE; }
261
-      if (event.keyCode == 90) { this.state.undo(); }
262
-      if (event.keyCode == 89) { this.state.redo(); }
263
-      if (event.keyCode == 88) { specialKeyCode = c.KEY_CUT; }
248
+      if (event.keyCode == 67) {
249
+        specialKeyCode = c.KEY_COPY;
250
+      }
251
+      if (event.keyCode == 86) {
252
+        specialKeyCode = c.KEY_PASTE;
253
+      }
254
+      if (event.keyCode == 90) {
255
+        this.state.undo();
256
+      }
257
+      if (event.keyCode == 89) {
258
+        this.state.redo();
259
+      }
260
+      if (event.keyCode == 88) {
261
+        specialKeyCode = c.KEY_CUT;
262
+      }
264 263
     }
265 264
 
266
-    if (event.keyCode == 8) { specialKeyCode = c.KEY_BACKSPACE; }
267
-    if (event.keyCode == 13) { specialKeyCode = c.KEY_RETURN; }
268
-    if (event.keyCode == 38) { specialKeyCode = c.KEY_UP; }
269
-    if (event.keyCode == 40) { specialKeyCode = c.KEY_DOWN; }
270
-    if (event.keyCode == 37) { specialKeyCode = c.KEY_LEFT; }
271
-    if (event.keyCode == 39) { specialKeyCode = c.KEY_RIGHT; }
265
+    if (event.keyCode == 8) {
266
+      specialKeyCode = c.KEY_BACKSPACE;
267
+    }
268
+    if (event.keyCode == 13) {
269
+      specialKeyCode = c.KEY_RETURN;
270
+    }
271
+    if (event.keyCode == 38) {
272
+      specialKeyCode = c.KEY_UP;
273
+    }
274
+    if (event.keyCode == 40) {
275
+      specialKeyCode = c.KEY_DOWN;
276
+    }
277
+    if (event.keyCode == 37) {
278
+      specialKeyCode = c.KEY_LEFT;
279
+    }
280
+    if (event.keyCode == 39) {
281
+      specialKeyCode = c.KEY_RIGHT;
282
+    }
272 283
 
273 284
     if (specialKeyCode != null) {
274 285
       //event.preventDefault();
@@ -277,4 +288,3 @@ export default class Controller {
277 288
     }
278 289
   }
279 290
 }
280
-

+ 8
- 9
js-lib/draw/index.js View File

@@ -1,9 +1,8 @@
1
-export { default as DrawFunction } from './function';
2
-export { default as DrawBox } from './box';
3
-export { default as DrawBoxText } from './boxtext';
4
-export { default as DrawErase } from './erase';
5
-export { default as DrawLine } from './line';
6
-export { default as DrawSelect } from './select';
7
-export { default as DrawText } from './text';
8
-export { default as DrawMove } from './move';
9
-export { default as DrawFreeform } from './freeform';
1
+export { default as DrawFunction } from "./function";
2
+export { default as DrawBox } from "./box";
3
+export { default as DrawErase } from "./erase";
4
+export { default as DrawLine } from "./line";
5
+export { default as DrawSelect } from "./select";
6
+export { default as DrawText } from "./text";
7
+export { default as DrawMove } from "./move";
8
+export { default as DrawFreeform } from "./freeform";

Loading…
Cancel
Save