You're quite right, David. 
But the parameter is used by some functions, while the setTarget is used by 
functions that 
write GUI controls. There is a sound reason for that, but I am not able to 
explain it clearly 
since I still have some trouble with defining it in my mind.
Now I've verified that the setTarget does not work for this jmolResize, one 
needs to use the 
parameter.

I've just tested an improvement of jmolResize  (copy at the end of this) that 
is not tied to 
applet #0. If you don't give a target, if will default to applet zero and, in 
that case, you can 
omit the height too and it will default to the width (square applet). If you do 
specify the target 
number, then you must give both width and height (well, you can give height as 
"" and it will 
give you a square applet).
I will upload that so it gets included in the next Jmol.js


On the other hand, it seems to me that this jmolResize function is a bit out of 
context. It 
dates from 2007 and was probably written before the applets were made 
resizable. In fact, if 
I am reading it right, it does either pixels or percent of window; if will not 
allow percent of 
container, which would be mre coherent with the current applet sizing ways.
Guess it could be rewritten in a more "modern" way, but if it works and covers 
a need we 
can leave it as such for now.


function jmolResize(w,h,targetSuffix)           // redefines that in Jmol.js
{       /*
        Resizes absolutely (pixels) or by percent of window (w or h 0.5 means 
50%).
        targetSuffix is optional and defaults to zero (first applet in page).
        Both w and h are optional, but needed if you want to use targetSuffix.
                h defaults to w
                w defaults to 100% of window
        If either w or h is between 0 and 1, then it is taken as percent/100.
        If either w or h is greater than 1, then it is taken as a size 
(pixels). 
        */

 _jmol.alerted = true;
 var percentW = (!w ? 100 : w <= 1  && w > 0 ? w * 100 : 0)
 var percentH = (!h ? percentW : h <= 1 && h > 0 ? h * 100 : 0)
 if (_jmol.browser=="msie") {
   var width=document.body.clientWidth;
   var height=document.body.clientHeight;
 } else {
   var netscapeScrollWidth=15;
   var width=window.innerWidth - netscapeScrollWidth;
   var height=window.innerHeight-netscapeScrollWidth;
 }
 var applet = _jmolGetApplet(targetSuffix);
 if(!applet)return;
 applet.style.width = (percentW ? width * percentW/100 : w)+"px"
 applet.style.height = (percentH ? height * percentH/100 : (h ? h : w) )+"px"
 title=width +  " " + height + " " + (new Date())       // what is this for?
}



------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Jmol-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-users

Reply via email to