Partial support for resizing around arrows

This commit is contained in:
Lewis Hemens 2014-04-27 13:57:15 +01:00
parent 3d5336b262
commit b63c778cc3
2 changed files with 237 additions and 205 deletions

View File

@ -2,9 +2,9 @@ var f;
try {
throw 1;
} catch (aa) {
window.O = window.O || {};
window.Q = window.Q || {};
}
var g = ["+", "\u2012", "\u2013", "-"], m = [">", "<", "^", "v"], ba = g.concat(m), n = "ontouchstart" in window || "onmsgesturechange" in window;
var h = ["+", "\u2012", "\u2013", "-"], m = [">", "<", "^", "v"], ba = h.concat(m), n = "ontouchstart" in window || "onmsgesturechange" in window;
function p(a, b) {
this.x = a;
this.y = b;
@ -28,25 +28,25 @@ p.prototype.scale = function(a) {
return new p(this.x * a, this.y * a);
};
function s(a, b) {
this.v = Math.min(a.x, b.x);
this.w = Math.min(a.y, b.y);
this.w = Math.min(a.x, b.x);
this.A = Math.min(a.y, b.y);
this.I = Math.max(a.x, b.x);
this.J = Math.max(a.y, b.y);
}
function t(a) {
return new p(a.v, a.w);
function u(a) {
return new p(a.w, a.A);
}
s.prototype.contains = function(a) {
return a.x >= this.v && a.x <= this.I && a.y >= this.w && a.y <= this.J;
return a.x >= this.w && a.x <= this.I && a.y >= this.A && a.y <= this.J;
};
var u = new p(-1, 0), v = new p(1, 0), w = new p(0, -1), z = new p(0, 1), A = [u, v, w, z];
var v = new p(-1, 0), w = new p(1, 0), x = new p(0, -1), A = new p(0, 1), B = [v, w, x, A];
function ca() {
this.g = this.value = null;
this.h = this.value = null;
}
function C(a) {
return null != a.g ? a.g : a.value;
return null != a.h ? a.h : a.value;
}
function D(a) {
function E(a) {
return-1 != ba.indexOf(C(a));
}
function da(a, b, c, d) {
@ -55,7 +55,7 @@ function da(a, b, c, d) {
this.l = c;
this.j = d;
}
function E(a) {
function F(a) {
return a.left + a.right + a.l + a.j;
}
function ea(a, b) {
@ -72,18 +72,18 @@ function fa(a, b) {
this.context = this.canvas.getContext("2d");
this.zoom = 1;
this.offset = new p(9E3, 5100);
this.e = !0;
this.A = !1;
this.f = !0;
this.B = !1;
ha(this);
}
function ha(a) {
a.canvas.width = document.documentElement.clientWidth;
a.canvas.height = document.documentElement.clientHeight;
a.e = !0;
a.f = !0;
}
ga.prototype.animate = function() {
if (this.e || this.state.e) {
this.e = !1, this.state.e = !1, ia(this);
if (this.f || this.state.f) {
this.f = !1, this.state.f = !1, ia(this);
}
var a = this;
window.requestAnimationFrame(function() {
@ -96,7 +96,7 @@ function ia(a) {
b.clearRect(0, 0, a.canvas.width, a.canvas.height);
b.scale(a.zoom, a.zoom);
b.translate(a.canvas.width / 2 / a.zoom, a.canvas.height / 2 / a.zoom);
var c = r(F(a, new p(0, 0)), new p(3, 3)), d = F(a, new p(a.canvas.width, a.canvas.height)).add(new p(3, 3));
var c = r(G(a, new p(0, 0)), new p(3, 3)), d = G(a, new p(a.canvas.width, a.canvas.height)).add(new p(3, 3));
c.x = Math.max(0, Math.min(c.x, 2E3));
d.x = Math.max(0, Math.min(d.x, 2E3));
c.y = Math.max(0, Math.min(c.y, 600));
@ -111,65 +111,65 @@ function ia(a) {
b.moveTo(0 - a.offset.x, 17 * e - a.offset.y), b.lineTo(9 * a.state.cells.length - a.offset.x, 17 * e - a.offset.y);
}
a.context.stroke();
e = !a.A;
e = !a.B;
b.font = "15px Courier New";
for (var h = c.x;h < d.x;h++) {
for (var g = c.x;g < d.x;g++) {
for (var l = c.y;l < d.y;l++) {
var k = G(a.state, new p(h, l));
if (D(k) || null != k.g && " " != C(k)) {
a.context.fillStyle = null != k.g ? "#DEF" : "#F5F5F5", b.fillRect(9 * h - a.offset.x, 17 * (l - 1) - a.offset.y, 9, 17);
var k = H(a.state, new p(g, l));
if (E(k) || null != k.h && " " != C(k)) {
a.context.fillStyle = null != k.h ? "#DEF" : "#F5F5F5", b.fillRect(9 * g - a.offset.x, 17 * (l - 1) - a.offset.y, 9, 17);
}
var x = ja(a.state, new p(h, l));
null == x || D(k) && !e || (a.context.fillStyle = "#000000", b.fillText(x, 9 * h - a.offset.x, 17 * l - a.offset.y - 3));
var y = ja(a.state, new p(g, l));
null == y || E(k) && !e || (a.context.fillStyle = "#000000", b.fillText(y, 9 * g - a.offset.x, 17 * l - a.offset.y - 3));
}
}
if (a.A) {
if (a.B) {
b.lineWidth = "1";
b.strokeStyle = "#000000";
b.beginPath();
for (e = c.x;e < d.x;e++) {
for (k = !1, h = c.y;h < d.y;h++) {
l = G(a.state, new p(e, h)), D(l) && h != d.y - 1 || !k || (b.moveTo(9 * e - a.offset.x + 4.5, 17 * k - a.offset.y - 8.5), b.lineTo(9 * e - a.offset.x + 4.5, 17 * (h - 1) - a.offset.y - 8.5), k = !1), D(l) && !k && (k = h);
for (k = !1, g = c.y;g < d.y;g++) {
l = H(a.state, new p(e, g)), E(l) && g != d.y - 1 || !k || (b.moveTo(9 * e - a.offset.x + 4.5, 17 * k - a.offset.y - 8.5), b.lineTo(9 * e - a.offset.x + 4.5, 17 * (g - 1) - a.offset.y - 8.5), k = !1), E(l) && !k && (k = g);
}
}
for (h = c.y;h < d.y;h++) {
for (g = c.y;g < d.y;g++) {
for (k = !1, e = c.x;e < d.x;e++) {
l = G(a.state, new p(e, h)), D(l) && e != d.x - 1 || !k || (b.moveTo(9 * k - a.offset.x + 4.5, 17 * h - a.offset.y - 8.5), b.lineTo(9 * (e - 1) - a.offset.x + 4.5, 17 * h - a.offset.y - 8.5), k = !1), D(l) && !k && (k = e);
l = H(a.state, new p(e, g)), E(l) && e != d.x - 1 || !k || (b.moveTo(9 * k - a.offset.x + 4.5, 17 * g - a.offset.y - 8.5), b.lineTo(9 * (e - 1) - a.offset.x + 4.5, 17 * g - a.offset.y - 8.5), k = !1), E(l) && !k && (k = e);
}
}
a.context.stroke();
}
}
function F(a, b) {
function G(a, b) {
return new p(Math.min(Math.max(1, Math.round(((new p((b.x - a.canvas.width / 2) / a.zoom + a.offset.x, (b.y - a.canvas.height / 2) / a.zoom + a.offset.y)).x - 4.5) / 9)), 1998), Math.min(Math.max(1, Math.round(((new p((b.x - a.canvas.width / 2) / a.zoom + a.offset.x, (b.y - a.canvas.height / 2) / a.zoom + a.offset.y)).y + 8.5) / 17)), 598));
}
;function H(a, b, c, d, e) {
;function I(a, b, c, d, e) {
e = e || "+";
var h = new s(b, c), l = h.v, k = h.w, x = h.I, h = h.J, y = d ? c.x : b.x;
for (d = d ? b.y : c.y;l++ < x;) {
var M = new p(l, d), B = a.getContext(new p(l, d));
" " == e && 2 == B.l + B.j || I(a, M, e);
var g = new s(b, c), l = g.w, k = g.A, y = g.I, g = g.J, z = d ? c.x : b.x;
for (d = d ? b.y : c.y;l++ < y;) {
var t = new p(l, d), D = a.getContext(new p(l, d));
" " == e && 2 == D.l + D.j || J(a, t, e);
}
for (;k++ < h;) {
M = new p(y, k), B = a.getContext(new p(y, k)), " " == e && 2 == B.left + B.right || I(a, M, e);
for (;k++ < g;) {
t = new p(z, k), D = a.getContext(new p(z, k)), " " == e && 2 == D.left + D.right || J(a, t, e);
}
J(a, b, e);
J(a, c, e);
I(a, new p(y, d), e);
K(a, b, e);
K(a, c, e);
J(a, new p(z, d), e);
}
function K(a) {
function L(a) {
this.state = a;
this.a = null;
}
f = K.prototype;
f = L.prototype;
f.start = function(a) {
this.a = a;
};
f.move = function(a) {
this.b = a;
L(this.state);
H(this.state, this.a, a, !0);
H(this.state, this.a, a, !1);
M(this.state);
I(this.state, this.a, a, !0);
I(this.state, this.a, a, !1);
};
f.end = function() {
N(this.state);
@ -177,22 +177,22 @@ f.end = function() {
f.k = function() {
return "crosshair";
};
f.f = function() {
f.g = function() {
};
function P(a, b) {
function O(a, b) {
this.state = a;
this.P = b;
this.R = b;
this.a = null;
}
f = P.prototype;
f = O.prototype;
f.start = function(a) {
this.a = a;
};
f.move = function(a) {
L(this.state);
M(this.state);
var b = this.state.getContext(this.a), c = this.state.getContext(a);
H(this.state, this.a, a, b.l && b.j || c.left && c.right);
this.P && J(this.state, a, "^");
I(this.state, this.a, a, b.l && b.j || c.left && c.right);
this.R && K(this.state, a, "^");
};
f.end = function() {
N(this.state);
@ -200,7 +200,7 @@ f.end = function() {
f.k = function() {
return "crosshair";
};
f.f = function() {
f.g = function() {
};
function ka(a, b) {
this.state = a;
@ -213,10 +213,10 @@ function ka(a, b) {
}
f = ka.prototype;
f.start = function(a) {
J(this.state, a, this.value);
K(this.state, a, this.value);
};
f.move = function(a) {
J(this.state, a, this.value);
K(this.state, a, this.value);
};
f.end = function() {
N(this.state);
@ -224,7 +224,7 @@ f.end = function() {
f.k = function() {
return "crosshair";
};
f.f = function(a) {
f.g = function(a) {
n && (this.value = $("#freeform-tool-input").val().substr(0, 1), $("#freeform-tool-input").blur(), $("#freeform-tool-input").hide(0));
1 == a.length && (this.value = a);
};
@ -237,8 +237,8 @@ f.start = function(a) {
N(this.state);
$("#text-tool-input").val("");
this.a = a;
a = C(G(this.state, this.a));
J(this.state, this.a, null == a ? "\u2009" : a);
a = C(H(this.state, this.a));
K(this.state, this.a, null == a ? "\u2009" : a);
};
f.move = function() {
};
@ -252,30 +252,30 @@ f.end = function() {
f.k = function() {
return "pointer";
};
f.f = function() {
f.g = function() {
var a = $("#text-tool-input").val();
L(this.state);
M(this.state);
for (var b = 0, c = 0, d = 0;d < a.length;d++) {
"\n" == a[d] ? (c++, b = 0) : (J(this.state, this.b.add(new p(b, c)), a[d]), b++);
"\n" == a[d] ? (c++, b = 0) : (K(this.state, this.b.add(new p(b, c)), a[d]), b++);
}
};
function Q(a) {
function P(a) {
this.state = a;
this.b = this.a = null;
}
f = Q.prototype;
f = P.prototype;
f.start = function(a) {
this.a = a;
this.move(a);
};
f.move = function(a) {
L(this.state);
M(this.state);
this.b = a;
var b = Math.min(this.a.x, this.b.x);
a = Math.min(this.a.y, this.b.y);
for (var c = Math.max(this.a.x, this.b.x), d = Math.max(this.a.y, this.b.y);b <= c;b++) {
for (var e = a;e <= d;e++) {
J(this.state, new p(b, e), "\u2009");
K(this.state, new p(b, e), "\u2009");
}
}
};
@ -285,50 +285,64 @@ f.end = function() {
f.k = function() {
return "crosshair";
};
f.f = function() {
f.g = function() {
};
function ma(a) {
this.state = a;
this.h = this.a = null;
this.e = this.a = null;
}
f = ma.prototype;
f.start = function(a) {
if (n && !D(G(this.state, a))) {
var b = A.concat([u.add(w), u.add(z), v.add(w), v.add(z)]), c = null, d = 0, e;
for (e in b) {
var h = a.add(b[e]), l = E(this.state.getContext(h));
D(G(this.state, h)) && l > d && (c = b[e], d = l);
var b;
if (n) {
if (E(H(this.state, a))) {
b = a;
} else {
b = B.concat([v.add(x), v.add(A), w.add(x), w.add(A)]);
var c = null, d = 0, e;
for (e in b) {
var g = a.add(b[e]), l = F(this.state.getContext(g));
E(H(this.state, g)) && l > d && (c = b[e], d = l);
}
b = null == c ? a : a.add(c);
}
a = null == c ? a : a.add(c);
} else {
b = a;
}
this.a = a;
this.h = null;
if (D(G(this.state, this.a))) {
this.a = b;
this.e = null;
if (E(H(this.state, this.a))) {
this.state.getContext(this.a);
a = [];
for (var k in A) {
var b = na(this, this.a, A[k]), x;
for (x in b) {
if (c = b[x], d = 0 != A[k].x, 1 == E(this.state.getContext(c))) {
a.push({position:c, D:d});
b = [];
for (var k in B) {
var c = na(this, this.a, B[k]), y;
for (y in c) {
if (d = c[y], e = 0 != B[k].x, g = -1 != m.indexOf(C(H(this.state, a))), l = -1 != m.indexOf(C(H(this.state, d))), 1 == F(this.state.getContext(d))) {
b.push({position:d, o:e, P:g, O:l});
} else {
for (var y in A) {
0 != A[k].add(A[y]).length() && 2 != A[k].add(A[y]).length() && (e = na(this, c, A[y]), 0 != e.length && a.push({position:e[e.length - 1], D:d}));
for (var z in B) {
if (0 != B[k].add(B[z]).length() && 2 != B[k].add(B[z]).length()) {
var t = na(this, d, B[z]);
0 != t.length && (t = t[0], b.push({position:t, o:e, P:g, S:l, O:-1 != m.indexOf(C(H(this.state, t)))}));
}
}
}
}
}
this.h = a;
this.e = b;
this.move(this.a);
}
};
f.move = function(a) {
L(this.state);
for (var b in this.h) {
H(this.state, this.a, this.h[b].position, this.h[b].D, " ");
M(this.state);
for (var b in this.e) {
I(this.state, this.a, this.e[b].position, this.e[b].o, " ");
}
for (b in this.h) {
H(this.state, a, this.h[b].position, this.h[b].D);
for (b in this.e) {
I(this.state, a, this.e[b].position, this.e[b].o);
}
for (b in this.e) {
this.e[b].P && K(this.state, a, "^"), this.e[b].O && K(this.state, this.e[b].position, "^"), this.e[b].S && K(this.state, new p(this.e[b].o ? this.e[b].position.x : a.x, this.e[b].o ? a.y : this.e[b].position.y), "^");
}
};
f.end = function() {
@ -336,49 +350,49 @@ f.end = function() {
};
function na(a, b, c) {
for (var d = b.clone(), e = [];;) {
var h = d.add(c);
if (!D(G(a.state, h))) {
var g = d.add(c);
if (!E(H(a.state, g))) {
return q(b, d) || e.push(d), e;
}
d = h;
3 == E(a.state.getContext(d)) && e.push(d);
d = g;
3 == F(a.state.getContext(d)) && e.push(d);
}
}
f.k = function(a) {
return D(G(this.state, a)) ? "pointer" : "default";
return E(H(this.state, a)) ? "pointer" : "default";
};
f.f = function() {
f.g = function() {
};
function oa(a) {
this.state = a;
this.F = this.o = this.b = this.a = null;
this.F = this.p = this.b = this.a = null;
this.K = !0;
this.u = null;
this.v = null;
}
f = oa.prototype;
f.start = function(a) {
null != this.a && null != this.b && (new s(this.a, this.b)).contains(a) ? (this.o = a, pa(this), qa(this, a)) : (this.a = a, this.b = null, this.K = !1, this.move(a));
null != this.a && null != this.b && (new s(this.a, this.b)).contains(a) ? (this.p = a, pa(this), qa(this, a)) : (this.a = a, this.b = null, this.K = !1, this.move(a));
};
function pa(a) {
var b = a.state.i.filter(function(a) {
return null != C(a.n) && "\u2009" != C(a.n);
}), c = t(new s(a.a, a.b));
a.u = b.map(function(a) {
}), c = u(new s(a.a, a.b));
a.v = b.map(function(a) {
return new ea(r(a.position, c), C(a.n));
});
}
f.move = function(a) {
if (null != this.o) {
if (null != this.p) {
qa(this, a);
} else {
if (!0 != this.K) {
this.b = a;
L(this.state);
M(this.state);
a = new s(this.a, a);
for (var b = a.v;b <= a.I;b++) {
for (var c = a.w;c <= a.J;c++) {
var d = new p(b, c), e = C(G(this.state, d));
J(this.state, d, null == e ? "\u2009" : e);
for (var b = a.w;b <= a.I;b++) {
for (var c = a.A;c <= a.J;c++) {
var d = new p(b, c), e = C(H(this.state, d));
K(this.state, d, null == e ? "\u2009" : e);
}
}
}
@ -386,29 +400,29 @@ f.move = function(a) {
};
function qa(a, b) {
a.F = b;
L(a.state);
var c = new Q(a.state);
M(a.state);
var c = new P(a.state);
c.start(a.a);
c.move(a.b);
c = r(a.F, a.o).add(t(new s(a.a, a.b)));
c = r(a.F, a.p).add(u(new s(a.a, a.b)));
ra(a, c);
}
function ra(a, b) {
for (var c in a.u) {
J(a.state, a.u[c].position.add(b), a.u[c].value);
for (var c in a.v) {
K(a.state, a.v[c].position.add(b), a.v[c].value);
}
}
f.end = function() {
null != this.o && (N(this.state), this.b = this.a = null);
this.F = this.o = null;
null != this.p && (N(this.state), this.b = this.a = null);
this.F = this.p = null;
this.K = !0;
};
f.k = function(a) {
return null != this.a && null != this.b && (new s(this.a, this.b)).contains(a) ? "pointer" : "default";
};
f.f = function(a) {
f.g = function(a) {
if (null != this.a && null != this.b && ("<copy>" != a && "<cut>" != a || pa(this), "<cut>" == a)) {
var b = new Q(this.state);
var b = new P(this.state);
b.start(this.a);
b.move(this.b);
N(this.state);
@ -418,7 +432,7 @@ f.f = function(a) {
function R() {
this.cells = Array(2E3);
this.i = [];
this.e = !0;
this.f = !0;
this.N = [];
this.M = [];
for (var a = 0;a < this.cells.length;a++) {
@ -431,31 +445,31 @@ function R() {
R.prototype.clear = function() {
for (var a = 0;a < this.cells.length;a++) {
for (var b = 0;b < this.cells[a].length;b++) {
null != C(this.cells[a][b]) && J(this, new p(a, b), "\u2009");
null != C(this.cells[a][b]) && K(this, new p(a, b), "\u2009");
}
}
N(this);
};
function G(a, b) {
function H(a, b) {
return a.cells[b.x][b.y];
}
function J(a, b, c) {
var d = G(a, b);
function K(a, b, c) {
var d = H(a, b);
a.i.push(new fa(b, d));
d.g = c;
a.e = !0;
d.h = c;
a.f = !0;
}
function I(a, b, c) {
C(G(a, b)) != c && J(a, b, c);
function J(a, b, c) {
C(H(a, b)) != c && K(a, b, c);
}
function L(a) {
function M(a) {
for (var b in a.i) {
a.i[b].n.g = null;
a.i[b].n.h = null;
}
a.i.length = 0;
}
function ja(a, b) {
var c = G(a, b), c = null != c.g ? c.g : c.value;
var c = H(a, b), c = null != c.h ? c.h : c.value;
if ("+" != c && "^" != c) {
return c;
}
@ -466,13 +480,13 @@ function ja(a, b) {
if (!d.left && !d.right && d.l && d.j) {
return "|";
}
if (4 == E(d)) {
if (4 == F(d)) {
return "-";
}
if ("+" == c && 3 == E(d)) {
if ("+" == c && 3 == F(d)) {
return "+";
}
if ("^" == c && 3 == E(d)) {
if ("^" == c && 3 == F(d)) {
if (!d.left) {
return "<";
}
@ -486,7 +500,7 @@ function ja(a, b) {
return ">";
}
}
if ("^" == c && 1 == E(d)) {
if ("^" == c && 1 == F(d)) {
if (d.left) {
return ">";
}
@ -503,8 +517,8 @@ function ja(a, b) {
return c;
}
R.prototype.getContext = function(a) {
var b = D(G(this, a.add(u))), c = D(G(this, a.add(v))), d = D(G(this, a.add(w)));
a = D(G(this, a.add(z)));
var b = E(H(this, a.add(v))), c = E(H(this, a.add(w))), d = E(H(this, a.add(x)));
a = E(H(this, a.add(A)));
return new da(b, c, d, a);
};
function N(a, b) {
@ -514,26 +528,26 @@ function N(a, b) {
return d.indexOf(d[b]) == b;
});
a.i.length = 0;
for (var h in e) {
var l = e[h].n;
c.push(new ea(e[h].position, null != l.value ? l.value : " "));
for (var g in e) {
var l = e[g].n;
c.push(new ea(e[g].position, null != l.value ? l.value : " "));
var k = C(l);
if ("\u2009" == k || " " == k) {
k = null;
}
l.g = null;
l.h = null;
l.value = k;
}
e = b ? a.M : a.N;
0 < c.length && (50 < e.length && e.shift(), e.push(c));
a.e = !0;
a.f = !0;
}
function sa(a) {
if (0 != a.N.length) {
var b = a.N.pop(), c;
for (c in b) {
var d = b[c];
J(a, d.position, d.value);
K(a, d.position, d.value);
}
N(a, !0);
}
@ -543,7 +557,7 @@ function ta(a) {
var b = a.M.pop(), c;
for (c in b) {
var d = b[c];
J(a, d.position, d.value);
K(a, d.position, d.value);
}
N(a);
}
@ -557,13 +571,13 @@ function S(a) {
if (0 > c.x) {
return "";
}
for (var h = "", e = b.y;e <= c.y;e++) {
for (var g = "", e = b.y;e <= c.y;e++) {
for (var l = "", d = b.x;d <= c.x;d++) {
var k = ja(a, new p(d, e)), l = l + (null == k ? " " : k)
}
h += l.replace("\\s+$/g", "") + "\n";
g += l.replace("\\s+$/g", "") + "\n";
}
return h;
return g;
}
function ua(a, b, c) {
b = b.split("\n");
@ -571,42 +585,42 @@ function ua(a, b, c) {
d.x = Math.max(d.x, Math.round(b[e].length / 2));
}
for (e = 0;e < b.length;e++) {
for (var h = b[e], l = 0;l < h.length;l++) {
var k = h.charAt(l);
-1 != g.indexOf(k) && (k = "+");
for (var g = b[e], l = 0;l < g.length;l++) {
var k = g.charAt(l);
-1 != h.indexOf(k) && (k = "+");
-1 != m.indexOf(k) && (k = "^");
J(a, r((new p(l, e)).add(c), d), k);
K(a, r((new p(l, e)).add(c), d), k);
}
}
}
;function T(a, b) {
this.view = a;
this.state = b;
this.d = new K(b);
this.d = new L(b);
this.mode = 0;
this.p();
this.r();
}
T.prototype.t = function(a) {
var b = F(this.view, a);
null == this.r && (this.r = b);
q(b, this.r) || (this.view.canvas.style.cursor = this.d.k(b));
2 != this.mode || q(b, this.r) || this.d.move(b);
T.prototype.u = function(a) {
var b = G(this.view, a);
null == this.s && (this.s = b);
q(b, this.s) || (this.view.canvas.style.cursor = this.d.k(b));
2 != this.mode || q(b, this.s) || this.d.move(b);
if (1 == this.mode) {
var c = this.view;
a = this.H.add(r(this.G, a).scale(1 / this.view.zoom));
c.offset = a;
c.e = !0;
c.f = !0;
}
this.r = b;
this.s = b;
};
function U(a) {
2 == a.mode && a.d.end();
a.mode = 0;
a.G = null;
a.H = null;
a.r = null;
a.s = null;
}
T.prototype.p = function() {
T.prototype.r = function() {
var a = this;
$(window).resize(function() {
ha(a.view);
@ -617,11 +631,11 @@ T.prototype.p = function() {
$("#draw-tools > button.tool").removeClass("active");
$("#" + a).toggleClass("active");
$(".dialog").removeClass("visible");
"box-button" == a && (this.d = new K(this.state));
"line-button" == a && (this.d = new P(this.state, !1));
"arrow-button" == a && (this.d = new P(this.state, !0));
"box-button" == a && (this.d = new L(this.state));
"line-button" == a && (this.d = new O(this.state, !1));
"arrow-button" == a && (this.d = new O(this.state, !0));
"freeform-button" == a && (this.d = new ka(this.state, "X"));
"erase-button" == a && (this.d = new Q(this.state));
"erase-button" == a && (this.d = new P(this.state));
"move-button" == a && (this.d = new ma(this.state));
"text-button" == a && (this.d = new la(this.state));
"select-button" == a && (this.d = new oa(this.state));
@ -643,7 +657,7 @@ T.prototype.p = function() {
}.bind(this));
$("#import-submit-button").click(function() {
this.state.clear();
ua(this.state, $("#import-area").val(), F(this.view, new p(this.view.canvas.width / 2, this.view.canvas.height / 2)));
ua(this.state, $("#import-area").val(), G(this.view, new p(this.view.canvas.width / 2, this.view.canvas.height / 2)));
N(this.state);
$("#import-area").val("");
$(".dialog").removeClass("visible");
@ -651,17 +665,17 @@ T.prototype.p = function() {
$("#use-lines-button").click(function() {
$(".dialog").removeClass("visible");
var a = this.view;
a.A = !0;
a.e = !0;
a.B = !0;
a.f = !0;
}.bind(this));
$("#use-ascii-button").click(function() {
$(".dialog").removeClass("visible");
var a = this.view;
a.A = !1;
a.e = !0;
a.B = !1;
a.f = !0;
}.bind(this));
$(window).keypress(function(a) {
a.ctrlKey || a.metaKey || 13 == a.keyCode || this.d.f(String.fromCharCode(a.keyCode));
a.ctrlKey || a.metaKey || 13 == a.keyCode || this.d.g(String.fromCharCode(a.keyCode));
}.bind(this));
$(window).keydown(function(a) {
var c = null;
@ -674,13 +688,13 @@ T.prototype.p = function() {
40 == a.keyCode && (c = "<down>");
37 == a.keyCode && (c = "<left>");
39 == a.keyCode && (c = "<right>");
null != c && this.d.f(c);
null != c && this.d.g(c);
}.bind(this));
$("#text-tool-input, #freeform-tool-input").keyup(function() {
this.d.f("");
this.d.g("");
}.bind(this));
$("#text-tool-input, #freeform-tool-input").change(function() {
this.d.f("");
this.d.g("");
}.bind(this));
$("#text-tool-close").click(function() {
$("#text-tool-widget").hide();
@ -688,13 +702,13 @@ T.prototype.p = function() {
}.bind(this));
};
function va(a, b) {
this.s = !1;
this.t = !1;
this.state = a;
this.view = b;
this.file = null;
wa(this);
$("#drive-button").click(function() {
this.s ? xa(this) : (V(this, !1), ya(this));
this.t ? xa(this) : (V(this, !1), ya(this));
}.bind(this));
$("#drive-filename").click(function() {
var a = "" + $("#drive-filename").text(), a = prompt("Enter new filename:", a);
@ -716,7 +730,7 @@ function va(a, b) {
}
function V(a, b) {
window.gapi.auth.authorize({client_id:"125643747010-9s9n1ne2fnnuh5v967licfkt83r4vba5.apps.googleusercontent.com", scope:"https://www.googleapis.com/auth/drive", immediate:b}, function(a) {
!a || a.error || this.s || (this.s = !0, $("#drive-button").addClass("active"), window.setTimeout(function() {
!a || a.error || this.t || (this.t = !0, $("#drive-button").addClass("active"), window.setTimeout(function() {
Ba(this);
}.bind(this), 500));
}.bind(a));
@ -728,7 +742,7 @@ function wa(a) {
}
function ya(a) {
window.setTimeout(function() {
this.s ? xa(this) : (V(this, !0), ya(this));
this.t ? xa(this) : (V(this, !0), ya(this));
}.bind(a), 1E3);
}
function Ca(a, b) {
@ -739,7 +753,7 @@ function Ca(a, b) {
function xa(a) {
$("#drive-dialog").addClass("visible");
var b = S(a.state);
5 < b.length && b != a.C && a.save();
5 < b.length && b != a.D && a.save();
za(a);
}
function za(a) {
@ -767,7 +781,7 @@ function W(a, b) {
}
}
function Aa(a) {
S(a.state) != a.C && a.file && a.file.editable && a.save();
S(a.state) != a.D && a.file && a.file.editable && a.save();
window.setTimeout(function() {
Aa(this);
}.bind(a), 5E3);
@ -778,7 +792,7 @@ va.prototype.save = function() {
W(Da(this, a), function(b) {
Ca(this, b);
$("#drive-save-state").text("Saved");
this.C = a;
this.D = a;
}.bind(this));
};
function Ba(a) {
@ -791,8 +805,8 @@ function Ea(a) {
Fa(a.file.downloadUrl, function(a) {
$("#drive-save-state").text("Loaded");
this.state.clear();
ua(this.state, a, F(this.view, new p(this.view.canvas.width / 2, this.view.canvas.height / 2)));
this.C = S(this.state);
ua(this.state, a, G(this.view, new p(this.view.canvas.width / 2, this.view.canvas.height / 2)));
this.D = S(this.state);
}.bind(a));
}
function Da(a, b) {
@ -813,16 +827,16 @@ function Fa(a, b) {
}
;function Ga(a) {
this.c = a;
this.p();
this.r();
}
Ga.prototype.p = function() {
Ga.prototype.r = function() {
var a = this.c.view.canvas;
$(a).bind("mousewheel", function(a) {
a = this.c.view.zoom * (0 < a.originalEvent.wheelDelta ? 1.1 : 0.9);
a = Math.max(Math.min(a, 5), 0.2);
var c = this.c.view;
c.zoom = a;
c.e = !0;
c.f = !0;
}.bind(this));
$(a).mousedown(function(a) {
if (a.ctrlKey || a.metaKey) {
@ -832,7 +846,7 @@ Ga.prototype.p = function() {
c.G = a;
c.H = c.view.offset;
} else {
c = this.c, a = new p(a.clientX, a.clientY), c.mode = 2, c.d.start(F(c.view, a));
c = this.c, a = new p(a.clientX, a.clientY), c.mode = 2, c.d.start(G(c.view, a));
}
}.bind(this));
$(a).mouseup(function() {
@ -842,41 +856,41 @@ Ga.prototype.p = function() {
U(this.c);
}.bind(this));
$(a).mousemove(function(a) {
this.c.t(new p(a.clientX, a.clientY));
this.c.u(new p(a.clientX, a.clientY));
}.bind(this));
};
function X(a) {
this.c = a;
this.B = this.m = !1;
this.p();
this.C = this.m = !1;
this.r();
}
function Ha(a, b) {
a.L = b;
a.R = $.now();
a.U = $.now();
a.m = !1;
window.setTimeout(function() {
if (!this.m && !this.B && null != this.L) {
if (!this.m && !this.C && null != this.L) {
var a = this.c;
a.mode = 2;
a.d.start(F(a.view, b));
a.d.start(G(a.view, b));
}
}.bind(a), 150);
}
X.prototype.t = function(a) {
if (!this.m && 150 > $.now() - this.R && 6 < r(a, this.L).length()) {
X.prototype.u = function(a) {
if (!this.m && 150 > $.now() - this.U && 6 < r(a, this.L).length()) {
this.m = !0;
var b = this.c;
b.mode = 1;
b.G = a;
b.H = b.view.offset;
}
this.c.t(a);
this.c.u(a);
};
X.prototype.reset = function() {
this.B = this.m = !1;
this.C = this.m = !1;
this.L = null;
};
X.prototype.p = function() {
X.prototype.r = function() {
var a = this.c.view.canvas;
$(a).bind("touchstart", function(a) {
a.preventDefault();
@ -887,22 +901,22 @@ X.prototype.p = function() {
var c = new p(a.originalEvent.touches[0].pageX, a.originalEvent.touches[0].pageY);
a = new p(a.originalEvent.touches[1].pageX, a.originalEvent.touches[1].pageY);
U(this.c);
this.B = !0;
this.C = !0;
this.m = !1;
this.S = r(c, a).length();
this.Q = this.c.view.zoom;
this.V = r(c, a).length();
this.T = this.c.view.zoom;
}
}
}.bind(this));
$(a).bind("touchmove", function(a) {
a.preventDefault();
if (1 == a.originalEvent.touches.length) {
this.t(new p(a.originalEvent.touches[0].pageX, a.originalEvent.touches[0].pageY));
this.u(new p(a.originalEvent.touches[0].pageX, a.originalEvent.touches[0].pageY));
} else {
if (1 < a.originalEvent.touches.length) {
var c = new p(a.originalEvent.touches[0].pageX, a.originalEvent.touches[0].pageY);
a = new p(a.originalEvent.touches[1].pageX, a.originalEvent.touches[1].pageY);
this.B && (c = this.Q * r(c, a).length() / this.S, c = Math.max(Math.min(c, 5), 0.5), a = this.c.view, a.zoom = c, a.e = !0);
this.C && (c = this.T * r(c, a).length() / this.V, c = Math.max(Math.min(c, 5), 0.5), a = this.c.view, a.zoom = c, a.f = !0);
}
}
}.bind(this));

View File

@ -370,11 +370,13 @@ ascii.DrawMove.prototype.start = function(position) {
// Clockwise is a lie, it is true if we move vertically first.
var clockwise = (DIRECTIONS[i].x != 0);
var startIsAlt = ALT_SPECIAL_VALUES.indexOf(this.state.getCell(position).getRawValue()) != -1;
var midPointIsAlt = ALT_SPECIAL_VALUES.indexOf(this.state.getCell(midPoint).getRawValue()) != -1;
var midPointContext = this.state.getContext(midPoint);
// Special case, a straight line with no turns.
if (midPointContext.sum() == 1) {
ends.push({position: midPoint, clockwise: clockwise});
ends.push({position: midPoint, clockwise: clockwise, startIsAlt: startIsAlt, endIsAlt: midPointIsAlt});
continue;
}
// Continue following lines from the midpoint.
@ -389,10 +391,12 @@ ascii.DrawMove.prototype.start = function(position) {
if (secondEnds.length == 0) {
continue;
}
var secondEnd = secondEnds[0];
var endIsAlt = ALT_SPECIAL_VALUES.indexOf(this.state.getCell(secondEnd).getRawValue()) != -1;
// On the second line we don't care about multiple
// junctions, just the last.
ends.push({position: secondEnds[secondEnds.length - 1],
clockwise: clockwise});
ends.push({position: secondEnd,
clockwise: clockwise, startIsAlt: startIsAlt, midPointIsAlt: midPointIsAlt, endIsAlt: endIsAlt});
}
}
}
@ -413,6 +417,20 @@ ascii.DrawMove.prototype.move = function(position) {
drawLine(this.state, position, this.ends[i].position,
this.ends[i].clockwise);
}
for (var i in this.ends) {
// If the ends or midpoint of the line was a alt character (arrow), need to preserve that.
if (this.ends[i].startIsAlt) {
this.state.drawValue(position, ALT_SPECIAL_VALUE);
}
if (this.ends[i].endIsAlt) {
this.state.drawValue(this.ends[i].position, ALT_SPECIAL_VALUE);
}
if (this.ends[i].midPointIsAlt) {
var midX = this.ends[i].clockwise ? this.ends[i].position.x : position.x;
var midY = this.ends[i].clockwise ? position.y : this.ends[i].position.y;
this.state.drawValue(new ascii.Vector(midX, midY), ALT_SPECIAL_VALUE);
}
}
};
/** @inheritDoc */