- Timestamp:
- 05/11/08 08:49:04 (7 months ago)
- Files:
-
- 1 modified
-
branches/1.1/dijit/_editor/plugins/FontChoice.js (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/1.1/dijit/_editor/plugins/FontChoice.js
r13175 r13688 72 72 return { label: label, name: name, value: value }; 73 73 }); 74 items.push({label: "", name:"", value:""}); // FilteringSelect doesn't like unmatched blank strings74 //items.push({label: "", name:"", value:""}); // FilteringSelect doesn't like unmatched blank strings 75 75 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( 78 77 { data: { identifier: "value", items: items } })}]); 79 78 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 } 80 111 this.button.setValue(""); 81 112 82 113 this.connect(this.button, "onChange", function(choice){ 83 114 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){ 88 116 this.editor.focus(); 89 this.editor._moveToBookmark(b);90 117 }else{ 91 118 // this.editor.focus(); … … 103 130 if(!_e || !_e.isLoaded || !_c.length){ return; } 104 131 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 } 106 139 // strip off single quotes, if any 107 140 var quoted = dojo.isString(value) && value.match(/'([^']*)'/); … … 128 161 value = {10:1, 13:2, 16:3, 18:4, 24:5, 32:6, 48:7}[pixels] || value; 129 162 } 163 130 164 this.updating = true; 131 165 this.button.setValue(value); … … 133 167 } 134 168 135 // FIXME: IE is *really* b0rken136 if(dojo.isIE){137 this._savedSelection = this.editor._getBookmark();138 }139 169 this._focusHandle = dijit.getFocus(this.editor.iframe); 140 170 },