Annotation of modules/damieng/graphical_editor/loncapa_daxe/web/nodes/textline.dart, revision 1.1

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) {
        !            29:     if ((parent is NumericalResponse && (parent as NumericalResponse).simpleUI) ||
        !            30:         (parent is FormulaResponse && (parent as FormulaResponse).simpleUI))
        !            31:       simpleUI = true;
        !            32:   }
        !            33:   
        !            34:   @override
        !            35:   h.Element html() {
        !            36:     simpleUI = (parent is NumericalResponse && (parent as NumericalResponse).simpleUI) ||
        !            37:         (parent is FormulaResponse && (parent as FormulaResponse).simpleUI);
        !            38:     if (!simpleUI)
        !            39:       return super.html();
        !            40:     // used like an attribute
        !            41:     h.TableRowElement tr = new h.TableRowElement();
        !            42:     tr.id = id;
        !            43:     
        !            44:     h.TableCellElement td = new h.TableCellElement();
        !            45:     td.classes.add('shrink');
        !            46:     tr.append(td);
        !            47:     
        !            48:     td = new h.TableCellElement();
        !            49:     td.classes.add('shrink');
        !            50:     td.text = LCDStrings.get('field_size');
        !            51:     td.classes.add('optional');
        !            52:     tr.append(td);
        !            53:     
        !            54:     td = new h.TableCellElement();
        !            55:     td.classes.add('expand');
        !            56:     String value = getAttribute('size');
        !            57:     h.TextInputElement input = new h.TextInputElement();
        !            58:     input.spellcheck = false;
        !            59:     input.size = 40;
        !            60:     if (value == null)
        !            61:       value = "20";
        !            62:     input.value = value;
        !            63:     input.onKeyUp.listen((h.KeyboardEvent event) {
        !            64:       DaxeAttr attr = new DaxeAttr('size', input.value);
        !            65:       doc.doNewEdit(new UndoableEdit.changeAttribute(this, attr));
        !            66:     });
        !            67:     input.classes.add('form_field');
        !            68:     td.append(input);
        !            69:     tr.append(td);
        !            70:     
        !            71:     td = new h.TableCellElement();
        !            72:     td.classes.add('shrink');
        !            73:     tr.append(td);
        !            74:     
        !            75:     return(tr);
        !            76:   }
        !            77:   
        !            78: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>