home *** CD-ROM | disk | FTP | other *** search
/ PC go! 2011 October / PCgo_1011_CD.iso / interface / js / pagger.js < prev    next >
Encoding:
JavaScript  |  2009-07-14  |  1.5 KB  |  66 lines

  1. // after site is loaded
  2. document.observe("dom:loaded", function() {
  3.     start = 1;
  4.     pos = 0;
  5.     limit = 6;
  6.     divs = $$('.teaserSmall');
  7.     browseDiv = $$('#browseBTN'); // Von Rene hinzugef├╝gt
  8.     parts = Math.ceil(divs.length/limit);
  9.     html = '';
  10.     
  11.     // ├änderung Rene - Damit die Navigationselemnte in der ├£bersicht nicht angezeigt werden
  12.     if( parts == 1 ){
  13.       browseDiv.each(function(e) {
  14.       e.hide();
  15.     });
  16.   }
  17.   // ├änderung Rene - Ende
  18.     
  19.     $R(1,parts).each(function(e,i) {
  20.         j = i+1;
  21.         if (start==j)
  22.         {
  23.             x = start;
  24.             jump = j;
  25.         }
  26.         else
  27.         {
  28.             x += limit;
  29.             jump = x;
  30.         }
  31.         html += '<a href="#" class="btn_browseNum" onclick="jump(-1,'+jump+','+j+')">'+j+'</a>';
  32.     });
  33.     $$('#browseBTN span')[0].insert(html);
  34.     _pos = function(position)
  35.     {
  36.         $$('#browseBTN span a').each(function(e,i) {
  37.             if (position == i)
  38.             {
  39.                 e.setStyle({ background: 'blue url(\'images/btn_browseNum.gif\') no-repeat 0px -21px' });
  40.             }
  41.             else
  42.             {
  43.                 e.setStyle({ background: 'blue url(\'images/btn_browseNum.gif\') no-repeat 0px 0px' });
  44.             }
  45.         });
  46.     }
  47.     page = function(start,position)
  48.     {
  49.         divs.each(function(e,i) {
  50.             e.hide();
  51.             if (i==start-1 || (i>start-1 && i<start-1+limit) ) {
  52.                 e.show();
  53.             };
  54.         });    
  55.         _pos(position);
  56.     }
  57.     jump = function(direction,jump,no)
  58.     {
  59.         if ((start==1&&direction==0) || (start==((parts-1)*limit+1)&&direction==1)) return;
  60.         start = (jump) ? jump : ((direction) ? start+limit : start-limit);
  61.         pos = (direction) ? pos+1 : pos-1;
  62.         pos = (no) ? no-1 : pos;
  63.         page(start,pos);
  64.     }
  65.     page(start,pos);
  66. });