Skip to content

Commit

Permalink
update to latest Dart
Browse files Browse the repository at this point in the history
  • Loading branch information
damien committed Jun 24, 2014
1 parent 9b7e7f2 commit 7aec438
Show file tree
Hide file tree
Showing 37 changed files with 124 additions and 120 deletions.
6 changes: 1 addition & 5 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
name: Daxe
name: daxe
author: Damien Guillaume
description: Dart XML Editor
dependencies:
browser: any
crypto: any
intl: any
meta: any

#dependencies:
# js: any
# unittest: any
2 changes: 1 addition & 1 deletion web/daxe.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ body {
}

button {
line-height: 1.2em;
padding: 2px;
}

div#insert {
Expand Down
4 changes: 2 additions & 2 deletions web/src/attribute_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class AttributeDialog {
else if (value != '' || defaultValue != null)
attributes[name] = new DaxeAttr.NS(namespace, name, value);
}
h.query('div#attributes_dlg').remove();
h.querySelector('div#attributes_dlg').remove();
event.preventDefault();
List<DaxeAttr> attList = new List.from(attributes.values);
if (el.getHTMLNode() != null) {
Expand All @@ -152,7 +152,7 @@ class AttributeDialog {
}

void cancel() {
h.query('div#attributes_dlg').remove();
h.querySelector('div#attributes_dlg').remove();
page.focusCursor();
}

Expand Down
4 changes: 2 additions & 2 deletions web/src/cursor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ class Cursor {
HashMap<int, ActionFunction> shortcuts;

Cursor() {
ta = h.query("#tacursor");
caret = h.query("#caret");
ta = h.querySelector("#tacursor");
caret = h.querySelector("#caret");
visible = true;
shortcuts = new HashMap<int, ActionFunction>();
// FIXME: IE is always intercepting Ctrl-P
Expand Down
2 changes: 1 addition & 1 deletion web/src/daxe.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import 'dart:collection';
//import 'dart:convert';
import 'dart:html' as h;

import 'package:meta/meta.dart';
//import 'package:meta/meta.dart';
//import 'package:js/js.dart' as js;

import 'xmldom/xmldom.dart' as x;
Expand Down
27 changes: 14 additions & 13 deletions web/src/daxe_node.dart
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ abstract class DaxeNode {
}
}
if (node is x.Element)
ref = doc.cfg.getElementRef(node as x.Element, parent == null ? null : parent.ref);
ref = doc.cfg.getElementRef(node, parent == null ? null : parent.ref);

if (createChildren) {
if (node.childNodes != null) {
Expand Down Expand Up @@ -325,6 +325,7 @@ abstract class DaxeNode {
i++;
}
assert(false);
return(-1);
}

String getAttribute(String name) {
Expand Down Expand Up @@ -734,7 +735,7 @@ abstract class DaxeNode {
hn.nodes.last is h.SpanElement) {
// we assume here that the spans are tags, not text with a \n inside
h.Element span_test = hn.nodes.first;
h.Rect box = span_test.getBoundingClientRect();
h.Rectangle box = span_test.getBoundingClientRect();
hnx1 = box.left;
hny1 = box.top;
lineHeight = span_test.offset.height.toDouble();
Expand All @@ -746,23 +747,23 @@ abstract class DaxeNode {
hn is h.TableElement || hn is h.ImageElement || hn.classes.contains('form')) {
// block
// for DivElement: no span to tag the div: we take the entire div into account
h.Rect box = hn.getBoundingClientRect();
h.Rectangle box = hn.getBoundingClientRect();
// FIXME: box is not good for a tr containing a td using rowspan
hnx1 = box.left;
hny1 = box.top;
if (hn.classes.contains('form')) // FIXME: this is a hack !
hnx2 = hn.query('table').getBoundingClientRect().right;
hnx2 = hn.querySelector('table').getBoundingClientRect().right;
else
hnx2 = box.right;
hny2 = box.bottom;
lineHeight = box.height;
} else if (hn is h.SpanElement && hn.nodes.length == 1 && hn.nodes.first is h.Text &&
!hn.nodes.first.nodeValue.endsWith('\n')) {
// text node that does not end with \n
List<h.Rect> rects = hn.getClientRects();
List<h.Rectangle> rects = hn.getClientRects();
if (rects.length == 0)
return(null);
h.Rect box = rects.first;
h.Rectangle box = rects.first;
hnx1 = box.left;
hny1 = box.top;
box = rects.last;
Expand All @@ -775,10 +776,10 @@ abstract class DaxeNode {
// span with a text node at the end which does not end with \n
// note: possibles selections on the text make the tests a bit complex...
h.Element span_test = hn.nodes.first;
List<h.Rect> rects = span_test.getClientRects();
List<h.Rectangle> rects = span_test.getClientRects();
if (rects.length == 0)
return(null);
h.Rect box = rects.first;
h.Rectangle box = rects.first;
hnx1 = box.left;
hny1 = box.top;
span_test = hn.nodes.last;
Expand All @@ -802,7 +803,7 @@ abstract class DaxeNode {
hn.append(span_test);
else
hn.insertBefore(span_test, hn.nodes.first);
h.Rect box = span_test.getBoundingClientRect();
h.Rectangle box = span_test.getBoundingClientRect();
hnx1 = box.left;
hny1 = box.top;
lineHeight = span_test.offset.height.toDouble();
Expand Down Expand Up @@ -849,8 +850,8 @@ abstract class DaxeNode {
if (nodeValue[pp + i] != '\n') {
range.setStart(ht, i);
range.setEnd(ht, i+1);
List<h.Rect> rects = range.getClientRects();
for (h.Rect r in rects) {
List<h.Rectangle> rects = range.getClientRects();
for (h.Rectangle r in rects) {
if (i < nodeValue.length - 1 && r.left == r.right &&
x < r.left && y < r.bottom) {
//print("left of line start after newline");
Expand All @@ -876,9 +877,9 @@ abstract class DaxeNode {
ht.text = "${s.substring(0, i)}|${s.substring(i)}";
range.setStart(ht, i);
range.setEnd(ht, i+1);
List<h.Rect> rects = range.getClientRects();
List<h.Rectangle> rects = range.getClientRects();
ht.text = s;
for (h.Rect r in rects) {
for (h.Rectangle r in rects) {
if (x > r.left && y <= r.bottom) {
//print("right of \\n");
// to the right of the last character on the line
Expand Down
10 changes: 5 additions & 5 deletions web/src/equations/equation_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,13 @@ class EquationDialog {
}

void ok(h.MouseEvent event) {
h.TextAreaElement ta = h.query('textarea#eqtext');
h.TextAreaElement ta = h.querySelector('textarea#eqtext');
_equationText = ta.value;
if (_labelName != null) {
h.TextInputElement input_label = h.query('input#eqlabel');
h.TextInputElement input_label = h.querySelector('input#eqlabel');
_labelValue = input_label.value;
}
h.query('div#dlg1').remove();
h.querySelector('div#dlg1').remove();
if (event != null)
event.preventDefault();
if (_okfct != null)
Expand Down Expand Up @@ -129,14 +129,14 @@ class EquationDialog {
}

void updateDisplay() {
h.TextAreaElement ta = h.query('textarea#eqtext');
h.TextAreaElement ta = h.querySelector('textarea#eqtext');
_equationText = ta.value;
if (_equationText.length > 0 && _equationText.contains('\n')) {
ta.value = _equationText.replaceAll('\n', '');
ok(null);
return;
}
h.CanvasElement canvas = h.query('canvas#eqcanvas');
h.CanvasElement canvas = h.querySelector('canvas#eqcanvas');
StringMathBuilder sb = new StringMathBuilder(_equationText);
_base.setRootElement(sb.getMathRootElement());
_base.paint(canvas.context2D);
Expand Down
2 changes: 1 addition & 1 deletion web/src/equations/equations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/
library equations;

import 'package:meta/meta.dart';
//import 'package:meta/meta.dart';
import 'dart:html' as h;
import 'dart:math';

Expand Down
6 changes: 3 additions & 3 deletions web/src/equations/string_math_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -434,9 +434,9 @@ class JEQFonction implements JEQ {
final RegExp namesExpr = new RegExp("^[0-9]+.*\$");
JEQFonction(final JEQ nom, final List<JEQ> arguments) {
this.nom = nom;
if (nom is JEQVariable && namesExpr.hasMatch((nom as JEQVariable).nom)) {
if (nom is JEQVariable && namesExpr.hasMatch(nom.nom)) {
// un nom de fonction qui commence par des chiffres ?!?
(nom as JEQVariable).nom = "?";
nom.nom = "?";
}
vp = arguments;
if ((getNomFct() == "unité" || getNomFct() == "unit") && vp.length > 1 && vp[1] != null)
Expand Down Expand Up @@ -689,7 +689,7 @@ class JEQFonction implements JEQ {
// les vecteurs sont affichés en gras quand c'est possible
final MathElement mp1 = StringMathBuilder.elemOrQuestion(p1);
if (mp1 is MathIdentifier) {
(mp1 as MathIdentifier).setMathvariant("bold");
mp1.setMathvariant("bold");
me = mp1;
} else if (mp1 is MathSub && mp1.getMathElement(0) is MathIdentifier) {
(mp1.getMathElement(0) as MathIdentifier).setMathvariant("bold");
Expand Down
4 changes: 2 additions & 2 deletions web/src/find_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class FindDialog {
inputFind.focus();
return;
}
h.Element divdoc = h.query("#doc1");
h.Element divdoc = h.querySelector("#doc1");
divdoc.style.bottom = '10.5em';
div_find = new h.DivElement();
div_find.id = 'find_dlg';
Expand Down Expand Up @@ -264,7 +264,7 @@ class FindDialog {
void close() {
h.DivElement div_find = h.document.getElementById('find_dlg');
div_find.remove();
h.Element divdoc = h.query("#doc1");
h.Element divdoc = h.querySelector("#doc1");
divdoc.style.bottom = '1.5em';
page.focusCursor();
}
Expand Down
2 changes: 1 addition & 1 deletion web/src/insert_panel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ part of daxe;
class InsertPanel {

void update(Position pos) {
h.Element divInsert = h.query('div#insert');
h.Element divInsert = h.querySelector('div#insert');
for (h.Element child in divInsert.children)
child.remove();
if (pos == null)
Expand Down
2 changes: 1 addition & 1 deletion web/src/menu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class Menu extends MenuItem {
void hide() {
for (MenuItem item in items) {
if (item is Menu)
(item as Menu).hide();
item.hide();
}
h.DivElement div = getHTMLNode();
div.style.display = 'none';
Expand Down
4 changes: 2 additions & 2 deletions web/src/menu_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class MenuItem {
}

h.Element getHTMLNode() {
return(h.query("#menu_$id"));
return(h.querySelector("#menu_$id"));
}

void activate() {
Expand Down Expand Up @@ -118,7 +118,7 @@ class MenuItem {

void set title(String title) {
_title = title;
h.TableRowElement tr = h.query("#menu_$id");
h.TableRowElement tr = h.querySelector("#menu_$id");
h.TableCellElement td = tr.nodes.first;
td.text = title;
}
Expand Down
8 changes: 4 additions & 4 deletions web/src/menubar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ class MenuBar {
void docMouseUp(h.MouseEvent event) {
if (visibleMenu == null)
return;
h.DivElement divMenu = h.query("#menutitle_${visibleMenu.id}");
h.Rect r = divMenu.getBoundingClientRect();
h.DivElement divMenu = h.querySelector("#menutitle_${visibleMenu.id}");
h.Rectangle r = divMenu.getBoundingClientRect();
if (event.client.x < r.left || event.client.x > r.right ||
event.client.y < r.top || event.client.y > r.bottom) {
hideMenu(visibleMenu);
Expand All @@ -98,14 +98,14 @@ class MenuBar {

void showMenu(Menu m) {
visibleMenu = m;
h.DivElement divMenu = h.query("#menutitle_${m.id}");
h.DivElement divMenu = h.querySelector("#menutitle_${m.id}");
divMenu.classes.add('selected');
m.show();
}

void hideMenu(Menu m) {
visibleMenu = null;
h.DivElement divMenu = h.query("#menutitle_${m.id}");
h.DivElement divMenu = h.querySelector("#menutitle_${m.id}");
divMenu.classes.remove('selected');
m.hide();
}
Expand Down
16 changes: 8 additions & 8 deletions web/src/nodes/dn_equa_tex_mem.dart
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class DNEquaTexMem extends DaxeNode {
Object response = request.response;
// note : ByteBuffer and Uint8List are in dart:typed_data
if (response is ByteBuffer) {
Uint8List bytes = new Uint8List.view(response as ByteBuffer);
Uint8List bytes = new Uint8List.view(response);
String data = CryptoUtils.bytesToBase64(bytes);
completer.complete(data);
} else
Expand Down Expand Up @@ -254,14 +254,14 @@ class TeXEquationDialog {
}

void ok(h.MouseEvent event) {
h.TextAreaElement ta = h.query('textarea#eqtext');
h.TextAreaElement ta = h.querySelector('textarea#eqtext');
_equationText = ta.value;
// we can't always get the image data synchronously, this will be done later
if (_labelName != null) {
h.TextInputElement input_label = h.query('input#eqlabel');
h.TextInputElement input_label = h.querySelector('input#eqlabel');
_labelValue = input_label.value;
}
h.query('div#dlg1').remove();
h.querySelector('div#dlg1').remove();
if (event != null)
event.preventDefault();
if (_okfct != null)
Expand All @@ -275,7 +275,7 @@ class TeXEquationDialog {
void updateData() {
if (_equationText == '')
return(null);
h.ImageElement img = h.query('img#eqimg');
h.ImageElement img = h.querySelector('img#eqimg');
h.CanvasElement canvas = new h.CanvasElement(width: img.width, height: img.height);
h.CanvasRenderingContext2D context = canvas.context2D;
context.drawImage(img, 0, 0);
Expand All @@ -295,19 +295,19 @@ class TeXEquationDialog {
}

void updateImg() {
h.ImageElement img = h.query('img#eqimg');
h.ImageElement img = h.querySelector('img#eqimg');
img.src = getImgSrc();
}

void preview(h.MouseEvent event) {
event.preventDefault();
h.TextAreaElement ta = h.query('textarea#eqtext');
h.TextAreaElement ta = h.querySelector('textarea#eqtext');
_equationText = ta.value;
updateImg();
}

void checkReturn() {
h.TextAreaElement ta = h.query('textarea#eqtext');
h.TextAreaElement ta = h.querySelector('textarea#eqtext');
String text = ta.value;
if (text.length > 0 && text.contains('\n')) {
ta.value = text.replaceAll('\n', '');
Expand Down
2 changes: 1 addition & 1 deletion web/src/nodes/dn_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ class DNForm extends DaxeNode {
@override
void updateAttributes() {
h.DivElement div = getHTMLNode();
h.TableElement table = h.query("#$id>table");
h.TableElement table = h.querySelector("#$id>table");
int i = 0;
for (x.Element refAttr in attRefs) {
String name = doc.cfg.attributeQualifiedName(ref, refAttr);
Expand Down
6 changes: 3 additions & 3 deletions web/src/nodes/dn_special.dart
Original file line number Diff line number Diff line change
Expand Up @@ -200,20 +200,20 @@ class SpecialDialog {
return;
selectedTD.style.border = '1px solid black';
character = selectedTD.text;
h.ButtonElement bOk = h.query('button#special_ok');
h.ButtonElement bOk = h.querySelector('button#special_ok');
bOk.disabled = false;
}

void ok(h.MouseEvent event) {
h.query('div#dlg1').remove();
h.querySelector('div#dlg1').remove();
if (event != null)
event.preventDefault();
if (okfct != null)
okfct();
}

void cancel() {
h.query('div#dlg1').remove();
h.querySelector('div#dlg1').remove();
page.focusCursor();
}

Expand Down
Loading

0 comments on commit 7aec438

Please sign in to comment.