home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Internet 2000 December / MICD_2000_12_NR1.iso / FuturesClub / biblioteka.js < prev    next >
Text File  |  2000-11-08  |  6KB  |  173 lines

  1. /********************************************/
  2. /* BIBLIOTEKA Cross-Browser DHTML           */
  3. /* wersja 2         1999-05-03              */
  4. /********************************************/
  5. /* onFocus Dynamic Web Design               */
  6. /* Ania KrΩglewska, Pawe│ Postupalski       */
  7. /* mailto:onfocus@webmedia.pl               */
  8. /* http://www.onfocus.com.pl                */
  9. /********************************************/
  10. /* Ta biblioteka moze byc wykorzystywana    */
  11. /* bez zadnych ograniczen pod warunkiem     */
  12. /* zachowania tej informacji                */
  13. /********************************************/
  14.  
  15. /*************************/
  16. /* Detekcja przegladarki */
  17. /*************************/
  18. nn4 = (document.layers) ? true:false;
  19. ie4 = (document.all) ? true:false;
  20.  
  21. /**********************/
  22. /* Pokaz blok 'ident' */
  23. /**********************/
  24. function show(ident,nest) {
  25.     if(nn4) {    
  26.         nest ? document.layers[nest].document.layers[ident].visibility = "show" : document.layers[ident].visibility = "show";
  27.     } else if(ie4) {    
  28.         document.all[ident].style.visibility = "visible";
  29.     }
  30. }
  31.  
  32. /**********************/
  33. /* Ukryj blok 'ident' */
  34. /**********************/
  35. function hide(ident,nest) {
  36.     if(nn4) {    
  37.         nest ? document.layers[nest].document.layers[ident].visibility = "hide" : document.layers[ident].visibility = "hide";
  38.     } else if(ie4) {
  39.         document.all[ident].style.visibility = "hidden";
  40.     }
  41. }
  42.  
  43. /****************************************/
  44. /* Przesun blok 'ident' do punktu (x,y) */
  45. /****************************************/
  46. function moveTo(ident,x,y,nest) {
  47.     if(nn4) {
  48.         nest ? document.layers[nest].document.layers[ident].left = x : document.layers[ident].left = x;
  49.         nest ? document.layers[nest].document.layers[ident].top = y : document.layers[ident].top = y;
  50.     } else if(ie4) {
  51.         document.all[ident].style.left = x;
  52.         document.all[ident].style.top = y;
  53.     }
  54. }
  55.  
  56. /*****************************************/
  57. /* Przesun blok 'ident' o wektor [dx,dy] */
  58. /*****************************************/
  59. function moveBy(ident,dx,dy,nest) {
  60.     if(nn4) {
  61.         nest ? document.layers[nest].document.layers[ident].left += dx : document.layers[ident].left += dx;
  62.         nest ? document.layers[nest].document.layers[ident].top += dy : document.layers[ident].top += dy;
  63.     } else if(ie4) {
  64.         document.all[ident].style.left = document.all[ident].offsetLeft + dx;
  65.         document.all[ident].style.top = document.all[ident].offsetTop + dy;
  66.     }
  67. }
  68.  
  69. /************************************************/
  70. /* Przytnij blok 'ident' do zadanego prostokata */
  71. /*     t: top, r: right, b: bottom, l:left      */
  72. /************************************************/
  73. function clipTo(ident, t, r, b, l,nest) {
  74.     if(nn4) {
  75.         if(nest) {
  76.             document.layers[nest].document.layers[ident].clip.top = t;
  77.            document.layers[nest].document.layers[ident].clip.right = r;
  78.              document.layers[nest].document.layers[ident].clip.bottom = b;
  79.            document.layers[nest].document.layers[ident].clip.left = l;
  80.         } else {
  81.             document.layers[ident].clip.top = t;
  82.            document.layers[ident].clip.right = r;
  83.              document.layers[ident].clip.bottom = b;
  84.            document.layers[ident].clip.left = l;
  85.         }
  86.     } else if(ie4) {
  87.          document.all[ident].style.clip = 
  88.         "rect(" + t + " " + r + " " + b + " " + l + ")";
  89.     }
  90. }
  91.  
  92. /****************************************************/
  93. /* Zmien przyciecie bloku 'ident' o zadane wartosci */
  94. /*     t: top, r: right, b: bottom, l:left          */
  95. /****************************************************/
  96. function clipBy(ident, t, r, b, l,nest) {
  97.     if(nn4) {
  98.         if(nest) {
  99.             document.layers[nest].document.layers[ident].clip.top += t;
  100.             document.layers[nest].document.layers[ident].clip.right += r;
  101.             document.layers[nest].document.layers[ident].clip.bottom += b;
  102.             document.layers[nest].document.layers[ident].clip.left += l;
  103.         } else {
  104.             document.layers[ident].clip.top += t;
  105.             document.layers[ident].clip.right += r;
  106.             document.layers[ident].clip.bottom += b;
  107.             document.layers[ident].clip.left += l;
  108.         }
  109.     } else if(ie4) {
  110.         ie_clip = document.all[ident].style.clip;
  111.         ie_clip = ie_clip.substring(5, ie_clip.length-1);
  112.         ie_clip_wart = ie_clip.split("px");
  113.         t += parseInt(ie_clip_wart [0]);
  114.         r += parseInt(ie_clip_wart [1]);
  115.         b += parseInt(ie_clip_wart [2]);
  116.         l += parseInt(ie_clip_wart [3]);
  117.             
  118.         document.all[ident].style.clip = 
  119.             "rect(" + t + "px " + r + "px " + b + "px " + l + "px)";
  120.     }
  121. }
  122.  
  123. /***********************************************************/
  124. /* Zapisz pozycje bloku 'ident' do zmiennych l:left, t:top */
  125. /***********************************************************/
  126. function pozycja(ident,nest) {
  127.     if(nn4) {
  128.         l = nest ? document.layers[nest].document.layers[ident].left : document.layers[ident].left;
  129.         t = nest ? document.layers[nest].document.layers[ident].top : document.layers[ident].top;
  130.     } else if(ie4) {
  131.         l = document.all[ident].offsetLeft;
  132.         t = document.all[ident].offsetTop;
  133.     }
  134. }
  135.  
  136. /******************************************************/
  137. /* Zapisz wysokosc bloku 'ident' do zmienej h: height */
  138. /******************************************************/
  139. function wysokosc(ident,nest) {
  140.     if(nn4) {
  141.         h = nest ? document.layers[nest].document.layers[ident].document.height : document.layers[ident].document.height;
  142.     } else if(ie4) {
  143.         h = document.all[ident].scrollHeight;    
  144.     }
  145.     return h;
  146. }
  147.  
  148. /****************************************/
  149. /* Sprawdz rozmiary okna                */
  150. /*   oknoW: dostepna szerokosc          */
  151. /*   oknoH: dostepna wysokosc           */
  152. /****************************************/
  153. function okno(){
  154.     if(nn4){
  155.         oknoW=window.innerWidth-16;
  156.         oknoH=window.innerHeight
  157.     }else if(ie4){
  158.         oknoW=document.body.offsetWidth-20;
  159.         oknoH=document.body.offsetHeight
  160.     }
  161. }
  162.  
  163. /*************************/
  164. /* Przeladuj cala strone */
  165. /*************************/
  166. function reDo() {
  167.     if(nn4) {
  168.         if (innerWidth != oknoW+16 || innerHeight != oknoH) {
  169.             location.reload();
  170.         }
  171.     } else location.reload();
  172. }
  173.