Changeset 13688

Show
Ignore:
Timestamp:
05/11/08 08:49:04 (5 days ago)
Author:
liucougar
Message:

fixes #6729 in 1.1 branch

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/1.1/dijit/_editor/plugins/FontChoice.js

    r13175 r13688  
    7272                                return { label: label, name: name, value: value }; 
    7373                        }); 
    74                         items.push({label: "", name:"", value:""}); // FilteringSelect doesn't like unmatched blank strings 
     74                        //items.push({label: "", name:"", value:""}); // FilteringSelect doesn't like unmatched blank strings 
    7575 
    76                         dijit._editor.plugins.FontChoice.superclass._initButton.apply(this, 
    77                                 [{ labelType: "html", labelAttr: "label", searchAttr: "name", store: new dojo.data.ItemFileReadStore( 
     76                        this.inherited(arguments,[{ labelType: "html", labelAttr: "label", searchAttr: "name", store: new dojo.data.ItemFileReadStore( 
    7877                                        { data: { identifier: "value", items: items } })}]); 
    7978 
     79                        //overload isValid/setValue to not show any validate error: if invalid, just show empty in the widget 
     80                        this.button.isValid = function(){ return true; }; 
     81                        this.button.setValue = function(/*String*/ value, /*Boolean?*/ priorityChange){ 
     82                                //copied from FilteringSelect.setValue, just added one line 
     83                                //TODO: is there a better way to achieve this? or shall we add a hook to 
     84                                //FilteringSelect.setValue to allow inserting a _setValue more easily? 
     85                                var self=this; 
     86                                var handleFetchByIdentity = function(item, priorityChange){ 
     87                                        if(item){ 
     88                                                if(self.store.isItemLoaded(item)){ 
     89                                                        self._callbackSetLabel([item], undefined, priorityChange); 
     90                                                }else{ 
     91                                                        self.store.loadItem({ 
     92                                                                item: item,  
     93                                                                onItem: function(result, dataObject){ 
     94                                                                        self._callbackSetLabel(result, dataObject, priorityChange); 
     95                                                                } 
     96                                                        }); 
     97                                                } 
     98                                        }else{ 
     99                                                self._isvalid=false; 
     100                                                self.validate(false); 
     101                                                self._setValue('','',false); //added this line to reset the input field to empty 
     102                                        } 
     103                                } 
     104                                this.store.fetchItemByIdentity({ 
     105                                        identity: value,  
     106                                        onItem: function(item){ 
     107                                                handleFetchByIdentity(item, priorityChange); 
     108                                        } 
     109                                }); 
     110                        } 
    80111                        this.button.setValue(""); 
    81112 
    82113                        this.connect(this.button, "onChange", function(choice){ 
    83114                                if(this.updating){ return; } 
    84                                 // FIXME: IE is really messed up here!! 
    85                                 if(dojo.isIE && "_savedSelection" in this){ 
    86                                         var b = this._savedSelection; 
    87                                         delete this._savedSelection; 
     115                                if(dojo.isIE){ 
    88116                                        this.editor.focus(); 
    89                                         this.editor._moveToBookmark(b); 
    90117                                }else{ 
    91118//                                      this.editor.focus(); 
     
    103130                        if(!_e || !_e.isLoaded || !_c.length){ return; } 
    104131                        if(this.button){ 
    105                                 var value = _e.queryCommandValue(this.editor._normalizeCommand(_c)) || ""; 
     132                                var value; 
     133                                try{ 
     134                                        value = _e.queryCommandValue(_c) || ""; 
     135                                }catch(e){ 
     136                                        //Firefox may throw error above if the editor is just loaded, ignore it 
     137                                        value = ""; 
     138                                } 
    106139                                // strip off single quotes, if any 
    107140                                var quoted = dojo.isString(value) && value.match(/'([^']*)'/); 
     
    128161                                        value = {10:1, 13:2, 16:3, 18:4, 24:5, 32:6, 48:7}[pixels] || value; 
    129162                                } 
     163 
    130164                                this.updating = true; 
    131165                                this.button.setValue(value); 
     
    133167                        } 
    134168 
    135                         // FIXME: IE is *really* b0rken 
    136                         if(dojo.isIE){ 
    137                                 this._savedSelection = this.editor._getBookmark(); 
    138                         } 
    139169                        this._focusHandle = dijit.getFocus(this.editor.iframe); 
    140170                },