home *** CD-ROM | disk | FTP | other *** search
/ Freelog 115 / FreelogNo115-MaiJuin2013.iso / Internet / AvantBrowser / asetup.exe / _data / res / img.wktpl < prev    next >
Text File  |  2013-04-03  |  6KB  |  212 lines

  1. function AFI_RotateClockWise(){
  2.     var oImg = document.getElementById("_Avant_Force_Scripted_Picture_Element_000");
  3.     if(oImg == null) return;
  4.         
  5.     oImg.afi_zoom = 1;
  6.     oImg.afi_rotateAngle += 90;
  7.     oImg.afi_rotateAngle = oImg.afi_rotateAngle % 360;
  8.     AFI_ReloadImg();
  9. }
  10.  
  11. function AFI_RotateAntiClockWise(){
  12.     var oImg = document.getElementById("_Avant_Force_Scripted_Picture_Element_000");
  13.     if(oImg == null) return;
  14.         
  15.     oImg.afi_zoom = 1;
  16.     oImg.afi_rotateAngle -= 90;
  17.     oImg.afi_rotateAngle = (oImg.afi_rotateAngle + 360) % 360; 
  18.     AFI_ReloadImg();
  19. }
  20.  
  21. function AFI_FitImg(){
  22.     var oImg = document.getElementById("_Avant_Force_Scripted_Picture_Element_000");
  23.     if(oImg == null) return;
  24.         
  25.     oImg.afi_fitType++;
  26.  
  27.     if (oImg.afi_fitType>2)
  28.         oImg.afi_fitType=0;
  29.  
  30.     AFI_ReloadImg();
  31. }
  32.  
  33. function AFI_GetImgOriginalSize(aurl)
  34. {
  35.     var originImage=new Image();
  36.     originImage.src = aurl;
  37.     var ret =  {width:originImage.width, height:originImage.height};
  38.     delete originImage;
  39.     return ret;
  40. }
  41.  
  42. function AFI_GetWinSize(){
  43.     var oImg = document.getElementById("_Avant_Force_Scripted_Picture_Element_000");
  44.     if(oImg == null) return;
  45.         
  46.     var winSize = {width:0,height:0};
  47.     
  48.     winSize.width = window.innerWidth;
  49.     winSize.height = window.innerHeight;
  50.  
  51.     if (oImg.afi_fitType == 2) {  
  52.       winSize.width -=20;
  53.       winSize.height -=20;
  54.     } else {
  55.       //winSize.width -=2;
  56.       //winSize.height -=2;
  57.     }
  58.     return winSize;
  59. }
  60.  
  61. function AFI_GetPos(){
  62.     var oImg = document.getElementById("_Avant_Force_Scripted_Picture_Element_000");
  63.     if(oImg == null) return;
  64.         
  65.     var pos = {left:0,top:0,width:0,height:0};
  66.     
  67.     var oImg = document.getElementById("_Avant_Force_Scripted_Picture_Element_000");
  68.     var originalImgSize = {width:0,height:0};
  69.     originalImgSize = AFI_GetImgOriginalSize(oImg.src);
  70.     
  71.     if(originalImgSize.width ==0)
  72.     {
  73.         originalImgSize.width = oImg.offsetWidth;
  74.         originalImgSize.height = oImg.offsetHeight;
  75.     }
  76.     
  77.     var winSize = AFI_GetWinSize();
  78.     if((oImg.afi_rotateAngle == 0) || (oImg.afi_rotateAngle==180))
  79.     {
  80.         pos.width = originalImgSize.width ;
  81.         pos.height = originalImgSize.height;
  82.     }
  83.     else if((oImg.afi_rotateAngle == 90) || (oImg.afi_rotateAngle == 270))
  84.     {
  85.         pos.width = originalImgSize.height;
  86.         pos.height = originalImgSize.width;
  87.     }
  88.     else
  89.     {
  90.         //alert("wrong oImg.afi_rotateAngle !");
  91.     }
  92.  
  93.     var wScale = winSize.width/pos.width;
  94.     var hScale = winSize.height/pos.height;
  95.     
  96.     if(oImg.afi_fitType==0)
  97.     {
  98.         if((wScale < 1) || (hScale < 1))
  99.         {
  100.             if (wScale < hScale)
  101.             {
  102.                 oImg.afi_scale = wScale;
  103.             }
  104.             else
  105.             {
  106.                 oImg.afi_scale = hScale;
  107.             }
  108.         }
  109.         else
  110.         {
  111.             oImg.afi_scale = 1;
  112.         }
  113.               
  114.         pos.width = Math.floor(pos.width*oImg.afi_scale);
  115.         pos.height = Math.floor(pos.height*oImg.afi_scale);
  116.  
  117.     }
  118.     else if(oImg.afi_fitType==1)
  119.     {
  120.         oImg.afi_scale = 1;
  121.         pos.width = Math.floor(pos.width*oImg.afi_scale);
  122.         pos.height = Math.floor(pos.height*oImg.afi_scale);
  123.     }
  124.     else if(oImg.afi_fitType==2)
  125.     {
  126.         if((wScale < 1) || (hScale < 1))
  127.         {
  128.             if(wScale > hScale)
  129.             {
  130.                 oImg.afi_scale = wScale;
  131.             }
  132.             else
  133.             {
  134.                 oImg.afi_scale = hScale;
  135.             }
  136.         }
  137.         else
  138.         {
  139.             oImg.afi_scale = 1;
  140.         }
  141.               
  142.         pos.width = Math.floor(pos.width*oImg.afi_scale);
  143.         pos.height = Math.floor(pos.height*oImg.afi_scale);
  144.     }
  145.     else
  146.     {
  147.         oImg.afi_scale = oImg.afi_scale * oImg.afi_zoom;
  148.         pos.width = Math.floor(pos.width*oImg.afi_scale);
  149.         pos.height = Math.floor(pos.height*oImg.afi_scale);
  150.     }
  151.     
  152.     pos.left = 0;
  153.     pos.top = 0;
  154.     return pos;
  155. }
  156.  
  157. function AFI_ReloadImg(){
  158.     var oImg = document.getElementById("_Avant_Force_Scripted_Picture_Element_000");
  159.     if(oImg == null) return;
  160.  
  161.     var posObj = AFI_GetPos();
  162.  
  163.     document.body.style.position = "absolute";
  164.  
  165.     if((oImg.afi_rotateAngle == 90) ||(oImg.afi_rotateAngle ==270)){
  166.       oImg.width = posObj.height;
  167.       oImg.height = posObj.width;
  168.       oImg.style.left = (oImg.height - oImg.width) / 2;
  169.       oImg.style.top = (oImg.width - oImg.height) / 2;
  170.     }else{
  171.       oImg.width = posObj.width;
  172.       oImg.height = posObj.height;
  173.       oImg.style.left = 0;
  174.       oImg.style.top = 0;
  175.     }
  176.  
  177.     oImg.style.position = "absolute";
  178.     oImg.style.webkitTransform = 'rotate('+oImg.afi_rotateAngle+'deg)';
  179. }
  180.  
  181. function AFI_doResize(){
  182.     var oImg = document.getElementById("_Avant_Force_Scripted_Picture_Element_000");
  183.     if(oImg == null) return;
  184.         
  185.     if (!oImg.afi_inited) 
  186.       return;
  187.  
  188.     if (oImg.afi_fitType==1) 
  189.       return;
  190.       
  191.     AFI_ReloadImg();
  192. }
  193.  
  194. function AFI_InitImgFit(){
  195.     var oImg = document.getElementById("_Avant_Force_Scripted_Picture_Element_000");
  196.     if(oImg != null)
  197.         return;
  198.         
  199.     document.images[0].id = "_Avant_Force_Scripted_Picture_Element_000";
  200.     window.onresize = AFI_doResize;
  201.     
  202.     oImg = document.images[0];
  203.  
  204.     oImg.afi_fitType = 0;
  205.     oImg.afi_rotateAngle = 0;
  206.     oImg.afi_zoom = 1;
  207.     oImg.afi_scale = 1;
  208.     oImg.afi_inited = 0;
  209.     
  210.     AFI_ReloadImg();
  211.     oImg.afi_inited = 1;
  212. }