home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Freelog 115
/
FreelogNo115-MaiJuin2013.iso
/
Internet
/
AvantBrowser
/
asetup.exe
/
_data
/
res
/
img.wktpl
< prev
next >
Wrap
Text File
|
2013-04-03
|
6KB
|
212 lines
function AFI_RotateClockWise(){
var oImg = document.getElementById("_Avant_Force_Scripted_Picture_Element_000");
if(oImg == null) return;
oImg.afi_zoom = 1;
oImg.afi_rotateAngle += 90;
oImg.afi_rotateAngle = oImg.afi_rotateAngle % 360;
AFI_ReloadImg();
}
function AFI_RotateAntiClockWise(){
var oImg = document.getElementById("_Avant_Force_Scripted_Picture_Element_000");
if(oImg == null) return;
oImg.afi_zoom = 1;
oImg.afi_rotateAngle -= 90;
oImg.afi_rotateAngle = (oImg.afi_rotateAngle + 360) % 360;
AFI_ReloadImg();
}
function AFI_FitImg(){
var oImg = document.getElementById("_Avant_Force_Scripted_Picture_Element_000");
if(oImg == null) return;
oImg.afi_fitType++;
if (oImg.afi_fitType>2)
oImg.afi_fitType=0;
AFI_ReloadImg();
}
function AFI_GetImgOriginalSize(aurl)
{
var originImage=new Image();
originImage.src = aurl;
var ret = {width:originImage.width, height:originImage.height};
delete originImage;
return ret;
}
function AFI_GetWinSize(){
var oImg = document.getElementById("_Avant_Force_Scripted_Picture_Element_000");
if(oImg == null) return;
var winSize = {width:0,height:0};
winSize.width = window.innerWidth;
winSize.height = window.innerHeight;
if (oImg.afi_fitType == 2) {
winSize.width -=20;
winSize.height -=20;
} else {
//winSize.width -=2;
//winSize.height -=2;
}
return winSize;
}
function AFI_GetPos(){
var oImg = document.getElementById("_Avant_Force_Scripted_Picture_Element_000");
if(oImg == null) return;
var pos = {left:0,top:0,width:0,height:0};
var oImg = document.getElementById("_Avant_Force_Scripted_Picture_Element_000");
var originalImgSize = {width:0,height:0};
originalImgSize = AFI_GetImgOriginalSize(oImg.src);
if(originalImgSize.width ==0)
{
originalImgSize.width = oImg.offsetWidth;
originalImgSize.height = oImg.offsetHeight;
}
var winSize = AFI_GetWinSize();
if((oImg.afi_rotateAngle == 0) || (oImg.afi_rotateAngle==180))
{
pos.width = originalImgSize.width ;
pos.height = originalImgSize.height;
}
else if((oImg.afi_rotateAngle == 90) || (oImg.afi_rotateAngle == 270))
{
pos.width = originalImgSize.height;
pos.height = originalImgSize.width;
}
else
{
//alert("wrong oImg.afi_rotateAngle !");
}
var wScale = winSize.width/pos.width;
var hScale = winSize.height/pos.height;
if(oImg.afi_fitType==0)
{
if((wScale < 1) || (hScale < 1))
{
if (wScale < hScale)
{
oImg.afi_scale = wScale;
}
else
{
oImg.afi_scale = hScale;
}
}
else
{
oImg.afi_scale = 1;
}
pos.width = Math.floor(pos.width*oImg.afi_scale);
pos.height = Math.floor(pos.height*oImg.afi_scale);
}
else if(oImg.afi_fitType==1)
{
oImg.afi_scale = 1;
pos.width = Math.floor(pos.width*oImg.afi_scale);
pos.height = Math.floor(pos.height*oImg.afi_scale);
}
else if(oImg.afi_fitType==2)
{
if((wScale < 1) || (hScale < 1))
{
if(wScale > hScale)
{
oImg.afi_scale = wScale;
}
else
{
oImg.afi_scale = hScale;
}
}
else
{
oImg.afi_scale = 1;
}
pos.width = Math.floor(pos.width*oImg.afi_scale);
pos.height = Math.floor(pos.height*oImg.afi_scale);
}
else
{
oImg.afi_scale = oImg.afi_scale * oImg.afi_zoom;
pos.width = Math.floor(pos.width*oImg.afi_scale);
pos.height = Math.floor(pos.height*oImg.afi_scale);
}
pos.left = 0;
pos.top = 0;
return pos;
}
function AFI_ReloadImg(){
var oImg = document.getElementById("_Avant_Force_Scripted_Picture_Element_000");
if(oImg == null) return;
var posObj = AFI_GetPos();
document.body.style.position = "absolute";
if((oImg.afi_rotateAngle == 90) ||(oImg.afi_rotateAngle ==270)){
oImg.width = posObj.height;
oImg.height = posObj.width;
oImg.style.left = (oImg.height - oImg.width) / 2;
oImg.style.top = (oImg.width - oImg.height) / 2;
}else{
oImg.width = posObj.width;
oImg.height = posObj.height;
oImg.style.left = 0;
oImg.style.top = 0;
}
oImg.style.position = "absolute";
oImg.style.webkitTransform = 'rotate('+oImg.afi_rotateAngle+'deg)';
}
function AFI_doResize(){
var oImg = document.getElementById("_Avant_Force_Scripted_Picture_Element_000");
if(oImg == null) return;
if (!oImg.afi_inited)
return;
if (oImg.afi_fitType==1)
return;
AFI_ReloadImg();
}
function AFI_InitImgFit(){
var oImg = document.getElementById("_Avant_Force_Scripted_Picture_Element_000");
if(oImg != null)
return;
document.images[0].id = "_Avant_Force_Scripted_Picture_Element_000";
window.onresize = AFI_doResize;
oImg = document.images[0];
oImg.afi_fitType = 0;
oImg.afi_rotateAngle = 0;
oImg.afi_zoom = 1;
oImg.afi_scale = 1;
oImg.afi_inited = 0;
AFI_ReloadImg();
oImg.afi_inited = 1;
}