Annotation of modules/damieng/graphical_editor/loncapa_daxe/web/nodes/textline.dart, revision 1.2
1.1 damieng 1: /*
2: This file is part of LONCAPA-Daxe.
3:
4: LONCAPA-Daxe is free software: you can redistribute it and/or modify
5: it under the terms of the GNU General Public License as published by
6: the Free Software Foundation, either version 3 of the License, or
7: (at your option) any later version.
8:
9: LONCAPA-Daxe is distributed in the hope that it will be useful,
10: but WITHOUT ANY WARRANTY; without even the implied warranty of
11: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12: GNU General Public License for more details.
13:
14: You should have received a copy of the GNU General Public License
15: along with Daxe. If not, see <http://www.gnu.org/licenses/>.
16: */
17:
18: part of loncapa_daxe;
19:
20: /**
21: * Display for the textline element, for simple UI (the textline size is displayed like an attribute).
22: * Jaxe display type: 'textline'.
23: */
24: class Textline extends LCDBlock {
25:
26: Textline.fromRef(x.Element elementRef) : super.fromRef(elementRef);
27:
28: Textline.fromNode(x.Node node, DaxeNode parent) : super.fromNode(node, parent) {
1.2 ! damieng 29: if (simpleParent())
1.1 damieng 30: simpleUI = true;
31: }
32:
1.2 ! damieng 33: bool simpleParent() {
! 34: return (parent is LCDBlock && (parent as LCDBlock).simpleUI) &&
! 35: (parent is NumericalResponse || parent is FormulaResponse || parent is StringResponse);
! 36: }
! 37:
1.1 damieng 38: @override
39: h.Element html() {
1.2 ! damieng 40: simpleUI = simpleParent();
1.1 damieng 41: if (!simpleUI)
42: return super.html();
43: // used like an attribute
44: h.TableRowElement tr = new h.TableRowElement();
45: tr.id = id;
46:
47: h.TableCellElement td = new h.TableCellElement();
48: td.classes.add('shrink');
49: tr.append(td);
50:
51: td = new h.TableCellElement();
52: td.classes.add('shrink');
53: td.text = LCDStrings.get('field_size');
54: td.classes.add('optional');
55: tr.append(td);
56:
57: td = new h.TableCellElement();
58: td.classes.add('expand');
59: String value = getAttribute('size');
60: h.TextInputElement input = new h.TextInputElement();
61: input.spellcheck = false;
62: input.size = 40;
63: if (value == null)
64: value = "20";
65: input.value = value;
66: input.onKeyUp.listen((h.KeyboardEvent event) {
67: DaxeAttr attr = new DaxeAttr('size', input.value);
1.2 ! damieng 68: doc.doNewEdit(new UndoableEdit.changeAttribute(this, attr, updateDisplay:false));
1.1 damieng 69: });
70: input.classes.add('form_field');
71: td.append(input);
72: tr.append(td);
73:
74: td = new h.TableCellElement();
75: td.classes.add('shrink');
76: tr.append(td);
77:
78: return(tr);
79: }
80:
1.2 ! damieng 81: @override
! 82: void updateAttributes() {
! 83: if (!simpleUI) {
! 84: super.updateAttributes();
! 85: return;
! 86: }
! 87: parent.updateHTML();
! 88: }
1.1 damieng 89: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>