1. #1
    Ext JS Premium Member
    Join Date
    Mar 2007
    Location
    Germany
    Posts
    673
    Vote Rating
    9
    Dumbledore will become famous soon enough

      0  

    Default [BUG] htmleditor search for the font selector although enableFont is set to false

    [BUG] htmleditor search for the font selector although enableFont is set to false


    when i use the htmleditor component with enableFont=false an error occurs.
    Code:
    TypeError: me.down(...) is null
    [Bei diesem Fehler anhalten] 	
    
    select = me.down('#fontSelect').selectEl.dom;
    it seems a problem inside the initDefaultFont method. I fix it with an extra conditional


    Code:
    Ext.override(Ext.form.field.HtmlEditor, {
    
        initDefaultFont: function(){
            // It's not ideal to do this here since it's a write phase, but we need to know
            // what the font used in the textarea is so that we can setup the appropriate font
            // options in the select box. The select box will reflow once we populate it, so we want
            // to do so before we layout the first time.
            var me = this,
                selIdx = 0,
                fonts, font, select,
                option, i, len, lower;
            
            if (!me.defaultFont) {
                font = me.textareaEl.getStyle('font-family');
                font = Ext.String.capitalize(font.split(',')[0]);
                fonts = Ext.Array.clone(me.fontFamilies);
                Ext.Array.include(fonts, font);
                fonts.sort();
                me.defaultFont = font;
    
                // handle the select-box only if enableFont is true    <-----------
                if (me.enableFont){
                    select = me.down('#fontSelect').selectEl.dom;
                    for (i = 0, len = fonts.length; i < len; ++i) {
                        font = fonts[i];
                        lower = font.toLowerCase();
                        option = new Option(font, lower);
                        if (font == me.defaultFont) {
                            selIdx = i;
                        }
                        option.style.fontFamily = lower;
                        select.add(option);
                    }
                    // Old IE versions have a problem if we set the selected property
                    // in the loop, so set it after.
                    select.options[selIdx].selected = true;
                }
            }
        }
    });

  2. #2
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,992
    Vote Rating
    649
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    This is a known issue, should be fixed in the next release. Thanks for the post.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

Thread Participants: 1