Update of
/var/cvs/contributions/CMSContainer/cmsc/richtext/src/webapp/mmbase/edit/wizard/xinha/popups
In directory
james.mmbase.org:/tmp/cvs-serv7324/cmsc/richtext/src/webapp/mmbase/edit/wizard/xinha/popups
Modified Files:
insertinline_image.html
Log Message:
CMSC-1032 - Insert Image script does not calculate valid image sizes and
disables good features, fixed.
See also:
http://cvs.mmbase.org/viewcvs/contributions/CMSContainer/cmsc/richtext/src/webapp/mmbase/edit/wizard/xinha/popups
See also: http://www.mmbase.org/jira/browse/CMSC-1032
Index: insertinline_image.html
===================================================================
RCS file:
/var/cvs/contributions/CMSContainer/cmsc/richtext/src/webapp/mmbase/edit/wizard/xinha/popups/insertinline_image.html,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- insertinline_image.html 28 Jul 2008 08:40:38 -0000 1.5
+++ insertinline_image.html 28 Jul 2008 13:07:34 -0000 1.6
@@ -1,3 +1,4 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
@@ -32,6 +33,8 @@
document.getElementById("f_width").value = param["f_width"];
document.getElementById("f_height").value = param["f_height"];
document.getElementById("f_destination").value = param["f_destination"];
+ //Store the original sizes of image for aspect ratio
+ saveOriginalSizes();
}
if (document.getElementById("f_width").value == "") {
document.getElementById("f_align").value = "left";
@@ -120,6 +123,8 @@
}
}
+ //Store the original sizes of image for aspect ratio
+ saveOriginalSizes();
}
function onSelectPosition() {
@@ -187,37 +192,31 @@
<script type="text/javascript">
+ var width_orig = 1;
+ var height_orig = 1;
-var ratio = "";
-
-function saveRatio() {
- if ( ratio == "" || ratio == null ) {
- width = document.getElementById("f_width").value;
- height = document.getElementById("f_height").value;
- if ( width > height ) {
- ratio = ( width / height );
- } else if ( width < height ) {
- ratio = ( height / width );
- } else {
- ratio = 0;
- }
- }
+ function saveOriginalSizes() {
+ width_orig = document.getElementById("f_width").value;
+ height_orig = document.getElementById("f_height").value;
}
function calculateWidth() {
if ( document.getElementById("f_lock_ratio").checked ) {
- height = document.getElementById("f_height").value;
- document.getElementById("f_width").value = Math.round ( height / ratio)
;
+ var height = document.getElementById("f_height").value;
+ if (!isNaN(height) && height > 0) {
+ document.getElementById("f_width").value = Math.round
((width_orig / height_orig) * height);
+ }
}
}
function calculateHeight() {
if ( document.getElementById("f_lock_ratio").checked ) {
- width = document.getElementById("f_width").value;
- document.getElementById("f_height").value = Math.round ( width * ratio );
+ var width = document.getElementById("f_width").value;
+ if (!isNaN(width) && width > 0) {
+ document.getElementById("f_height").value = Math.round
((height_orig / width_orig) * width);
+ }
}
}
-
</script>
</head>
@@ -251,15 +250,15 @@
<div class="fl">Alignment:</div>
<select size="1" name="align" id="f_align" title="Positioning
of this image" onchange="onSelectPosition()">
<option value="">Not set</option>
- <option value="left" selected="1">Left</option>
+ <option value="left">Left</option>
<option value="right">Right</option>
- <option value="texttop" style="visibility:
hidden;">Texttop</option>
- <option value="absmiddle" style="visibility:
hidden;">Absmiddle</option>
- <option value="baseline" style="visibility:
hidden;">Baseline</option>
- <option value="absbottom" style="visibility:
hidden;">Absbottom</option>
- <option value="bottom" style="visibility:
hidden;">Bottom</option>
- <option value="middle" style="visibility:
hidden;">Middle</option>
- <option value="top" style="visibility: hidden;">Top</option>
+ <option value="texttop">Text top</option>
+ <option value="absmiddle">Abs middle</option>
+ <option value="baseline">Baseline</option>
+ <option value="absbottom">Abs bottom</option>
+ <option value="bottom">Bottom</option>
+ <option value="middle">Middle</option>
+ <option value="top">Top</option>
</select>
<p />
<div class="fl">Border thickness:</div>
@@ -270,10 +269,10 @@
<fieldset style="float:right; margin-right: 5px;">
<legend>Size</legend>
<div class="fr">Width:</div>
- <input type="text" name="width" id="f_width" size="5"
title="Width" onfocus="saveRatio();" onblur="calculateHeight();"
onchange="calculateHeight();" />
+ <input type="text" name="width" id="f_width" size="5"
title="Width" onblur="calculateHeight();" />
<p />
<div class="fr">Height:</div>
- <input type="text" name="height" id="f_height" size="5"
title="Height" onfocus="saveRatio();" onblur="calculateWidth();"
onchange="calculateWidth();" />
+ <input type="text" name="height" id="f_height" size="5"
title="Height" onblur="calculateWidth();" />
<p />
<div class="fr">Lock ratio:</div>
<input type="checkbox" name="lock_ratio" id="f_lock_ratio"
title="Lock aspect ratio" checked="checked" />
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs