PDA

View Full Version : [1.1.1] Incorrect width calculation for messagebox



tookoo
22 Feb 2008, 11:47 AM
When I have "<p>" tag inside the message string, the width of the MessageBox is not calculated correctly.
For example,


var str = "<p>If a use you wish to make of another's work is not within the appropriate Rule of Thumb, it may still be a fair use and can be analyzed using the Four Factor Fair Use Test.</p><p>This is the second paragraph!</p>";

Ext.MessageBox.alert("TEST ONLY", str);


I think that it would be nice if the MessageBox body text could support multiple paragraphs. After looking into the source code, I realized that in the function call of "updateText", msgEl.offsetWidth was not calculated correctly when a "<p>" is contained in the message text (it should be related to the fact that msgEl is a span). Changing it to "div" will fix the problem.

Suggested fixes:


getDialog : function(){
if(!dlg){
........
........
bodyEl = dlg.body.createChild({
html:'<div> class="ext-mb-text"></div><br /><input type="text" class="ext-mb-input" /><textarea class="ext-mb-textarea"></textarea><div class="ext-mb-progress-wrap"><div class="ext-mb-progress"><div class="ext-mb-progress-bar"> </div></div></div>'
});
........
........
}
return dlg;
},


I am using ext-1.1.1 right now. And the problem described above exists in both Firefox and IE. Thanks.

tookoo
22 Feb 2008, 11:53 AM
When I have "<p>" tag inside the message string, the width of the MessageBox is not calculated correctly.
For example,


var str = "<p>If a use you wish to make of another's work is not within the appropriate Rule of Thumb, it may still be a fair use and can be analyzed using the Four Factor Fair Use Test.</p><p>This is the second paragraph!</p>";

Ext.MessageBox.alert("TEST ONLY", str);


I think that it would be nice if the MessageBox body text could support multiple paragraphs. After looking into the source code, I realized that in the function call of "updateText", msgEl.offsetWidth was not calculated correctly when a "<p>" is contained in the message text (it should be related to the fact that msgEl is a span). Changing it to "div" will fix the problem.

Suggested fixes:


getDialog : function(){
if(!dlg){
........
........
bodyEl = dlg.body.createChild({
html:'<div> class="ext-mb-text"></div><br /><input type="text" class="ext-mb-input" /><textarea class="ext-mb-textarea"></textarea><div class="ext-mb-progress-wrap"><div class="ext-mb-progress"><div class="ext-mb-progress-bar"> </div></div></div>'
});
........
........
}
return dlg;
},


I am using ext-1.1.1 right now. And the problem described above exists in both Firefox and IE. The problem may also exist in ext-2.0.1. Thanks.