Changeset 3838


Ignore:
Timestamp:
Sep 9, 2009, 9:28:56 AM (15 years ago)
Author:
nikrou
Message:

navigation between picture (AK_NEXT, AK_PREVIOUS)

Location:
extensions/akBookStyle/trunk
Files:
1 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • extensions/akBookStyle/trunk/css/ak_style.css

    r3831 r3838  
    5757}
    5858
     59a.hide {
     60  visibility: hidden;
     61}
     62
    5963/******************/
    6064#theHeader, #menubar, .navigationBar, .titrePage {
  • extensions/akBookStyle/trunk/include/akContent.class.php

    r3830 r3838  
    3232    $this->plugin_config = $config;
    3333    $this->current_picture = 0;
     34    $this->next_picture = null;
     35    $this->previous_picture = null;
    3436  }
    3537
     
    5052    $template->assign('AK_DIR_THUMBNAIL', isset($GLOBALS['conf']['dir_thumbnail'])?$GLOBALS['conf']['dir_thumbnail']:'thumbnail');
    5153    $template->assign('AK_PREFIX_THUMBNAIL', $GLOBALS['conf']['prefix_thumbnail']);
    52     $template->assign('AK_PIC_SRC', get_image_url($images[$this->current_picture]));
    5354    $template->assign('AK_BY_LINE', $this->plugin_config->ak_by_line);
    5455    $template->assign('AK_MOUSE_EVENT', $this->plugin_config->ak_mouse_event);
     
    5859    $template->assign('AK_HORIZONTAL_TPL', AK_PLUGIN_TEMPLATE. '/ak_horizontal.tpl');
    5960    $template->assign('AK_THUMBNAILS_LOC', $this->plugin_config->ak_thumbnails_loc);
    60                 /* Thumbnail Nav */
    61                 if (!empty($page['navigation_bar'])) {
    62                         $nav = explode('|', $page['navigation_bar']);
    63                         if (substr($nav[1],1,2)=='<a') {
    64                                 $this->navbar['URL_PREV'] = substr($nav[1],10,stripos($nav[1],'" rel="'));
    65                         }
    66                         if (substr($nav[3],1,2)=='<a') {
    67                                 $this->navbar['URL_NEXT'] = substr($nav[3],10,stripos($nav[3],'" rel="'));
    68                         }
    69                         $template->assign('navbar', $this->navbar);
    70                 }
    71 }
     61    $template->assign('AK_PIC_SRC', get_image_url($images[$this->current_picture]));
     62
     63    $template->assign('AK_NEXT', $this->getNextPicture($this->current_picture, $images));
     64    $template->assign('AK_PREVIOUS', $this->getPreviousPicture($this->current_picture, $images));
     65  }
    7266
    7367  public function loc_end_index_thumbnails($tpl_vars, $images) {
     
    121115    }
    122116  }
     117
     118  private function getPreviousPicture($current, $images) {
     119    $previous = $current--;
     120    if ($previous>0) {
     121      return $this->makeAkUrl(array('ID' => $images[$previous]['id']));
     122    } else {
     123      return null;
     124    }
     125  }
     126
     127  private function getNextPicture($current, $images) {
     128    $index_current = null;
     129    foreach ($images as $index => $image) {
     130      if ($image['id']==$current) {
     131        $index_current = $index;
     132        break;
     133      }
     134    }
     135
     136    $next = $index_current+1;
     137    if ($next<count($images)) {
     138      return $this->makeAkUrl(array('ID' => $images[$next]['id']));
     139    } else {
     140      return null;
     141    }
     142  }
    123143}
    124144?>
  • extensions/akBookStyle/trunk/js/ak_jquery-load.js

    r3813 r3838  
    22    $("a.load")
    33      .bind(ak_mouse_event, function() {
    4           $('#akPicture').attr('src', $(this).children('img').attr('src').replace(dir_thumbnail+'\/'+prefix_thumbnail, ''));
     4          $a = $(this);
     5          $thumbnails = $('.thumbnails a[class="load"]');
     6          $nbThumbnails = $thumbnails.length;
     7
     8          $previous_link = $current_link = $next_link = null;
     9         
     10          $('.thumbnails a[class="load"]')
     11            .each( function(i) {
     12                if ($(this).attr('href')==$a.attr('href')) {
     13                  $current_link = $(this);
     14                  if (i>0) {
     15                    $previous_link = $thumbnails[i-1];
     16                  }
     17                  if (i<$nbThumbnails) {
     18                    $next_link = $thumbnails[i+1];
     19                  }
     20                }
     21              });
     22
     23          $current_link = $('.thumbnails a[href='+$(this).attr('href')+']');
     24          $src = $current_link.children('img').attr('src');
     25          $src = $src.replace(dir_thumbnail+'\/'+prefix_thumbnail, '');
     26
     27          $('#akPicture').attr('src', $src);
     28          if ($previous_link) {
     29            if ($('#akPreviousPicture').hasClass('hide')) {
     30              $('#akPreviousPicture').removeClass('hide');
     31            }
     32            $('#akPreviousPicture').attr('href', $($previous_link).attr('href'));
     33          } else {
     34            $('#akPreviousPicture').addClass('hide');
     35          }
     36          if ($next_link) {
     37            if ($('#akNextPicture').hasClass('hide')) {
     38              $('#akNextPicture').removeClass('hide');
     39            }
     40            $('#akNextPicture').attr('href', $($next_link).attr('href'));
     41          } else {
     42            $('#akNextPicture').addClass('hide');
     43          }
    544          return false;
    645        });
  • extensions/akBookStyle/trunk/template/ak_reloaded_image.tpl

    r3791 r3838  
    33  <table class="picture">
    44    <tr class="nline">
    5       <td class="ncol">
    6         {if isset($AK_PREVIOUS) }
    7 
    8         <a class="{$AK_PREVIOUS.load} navButton" href="{$AK_PREVIOUS.U_PIC}"
     5      <td class="ncol">
     6        <a id="akPreviousPicture" class="{if empty($AK_PREVIOUS)}hide {/if}load navButton" href="{$AK_PREVIOUS}"
    97           title="{'previous_page'|@translate} : {$AK_PREVIOUS.TITLE}"
    108           rel="prev">
     
    1210               class="button" alt="{'previous_page'|@translate}">
    1311        </a>
    14         {/if}
    1512      </td>
    1613    </tr>
     
    2421    <tr class="nline">
    2522      <td class="ncol">
    26         {if !empty($AK_NEXT) }
    27         <a class="{$AK_NEXT.load} navButton" href="{$AK_NEXT.U_PIC}"
     23        <a id="akNextPicture" class="{if empty($AK_NEXT)}hide {/if}load navButton" href="{$AK_NEXT}"
    2824           title="{'next_page'|@translate} : {$AK_NEXT.TITLE}"
    2925           rel="next">
     
    3127               class="button" alt="{'next_page'|@translate}">
    3228        </a>
    33         {/if}
    3429      </td>
    3530    </tr>
Note: See TracChangeset for help on using the changeset viewer.