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

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:     
1.3     ! damieng    44:     // the whole textline node is reduced to its size attribute
        !            45:     x.Element sizeRef = null;
        !            46:     for (x.Element refAttr in attRefs) {
        !            47:       String name = doc.cfg.attributeQualifiedName(ref, refAttr);
        !            48:       if (name == 'size') {
        !            49:         sizeRef = refAttr;
        !            50:         break;
        !            51:       }
        !            52:     }
        !            53:     assert(sizeRef != null);
1.1       damieng    54:     
1.3     ! damieng    55:     h.TableRowElement tr = attributeHTML(sizeRef);
        !            56:     tr.id = id;
        !            57:     tr.childNodes[1].text = LCDStrings.get('field_size');
1.1       damieng    58:     
                     59:     return(tr);
                     60:   }
                     61:   
1.2       damieng    62:   @override
                     63:   void updateAttributes() {
                     64:     if (!simpleUI) {
                     65:       super.updateAttributes();
                     66:       return;
                     67:     }
                     68:     parent.updateHTML();
                     69:   }
1.1       damieng    70: }

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