Ignore:
Timestamp:
02/12/10 17:28:21 (2 years ago)
Author:
MichaelDaum
Message:

Item176: optionally render galleries using a jQuery slimbox fronted

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ImageGalleryPlugin/lib/Foswiki/Plugins/ImageGalleryPlugin/Core.pm

    r4425 r6295  
    22# 
    33# Copyright (C) 2002-2009 Will Norris. All Rights Reserved. (wbniv@saneasylumstudios.com) 
    4 # Copyright (C) 2005-2009 Michael Daum http://michaeldaumconsulting.com 
     4# Copyright (C) 2005-2010 Michael Daum http://michaeldaumconsulting.com 
    55# 
    66# This program is free software; you can redistribute it and/or 
     
    1919 
    2020use strict; 
     21use Foswiki::Func (); 
     22use Foswiki::Plugins (); 
    2123use constant DEBUG => 0; # toggle me 
    2224use vars qw(%imageSuffixes); 
     
    4244 
    4345  $this->{id} = $id; 
     46  $this->{session} = $Foswiki::Plugins::SESSION; 
    4447  $this->{query} = Foswiki::Func::getCgiQuery(); 
    4548  $this->{topic} = $topic; 
     
    180183  $this->{minwidth} = $this->{maxwidth} if $this->{minwidth} > $this->{maxwidth}; 
    181184  $this->{format} = $params->{format}; 
     185  $this->{frontend} = $params->{frontend}; 
     186  $this->{header} = $params->{header}; 
     187  $this->{footer} = $params->{footer}; 
    182188  $this->{title} = $params->{title} || ' $comment ($imgnr/$nrimgs)'; 
    183189  $this->{doTitles} = ($this->{title} eq 'off')?0:1; 
     
    216222  $this->{reverse} = $params->{rev} || $params->{reverse} || 'off'; 
    217223  $this->{reverse} = 'off' unless $this->{reverse} =~ /^on|off$/; 
     224 
     225  unless (defined $this->{frontend}) { 
     226    $this->{frontend} = (Foswiki::Func::getContext()->{JQueryPluginEnabled})?'lightbox':'default'; 
     227  } 
    218228 
    219229  return 1; 
     
    275285  my $id = $this->{query}->param("id") || ''; 
    276286 
    277   if ($this->{format}) { 
     287  if ($this->{frontend} eq 'lightbox') { 
     288    require Foswiki::Plugins::JQueryPlugin; 
     289    Foswiki::Plugins::JQueryPlugin::createPlugin('slimbox'); 
     290    $this->{header} = "<noautolink><div class=\"igp jqSlimbox {itemSelector:'.igpThumbNail', singleMode:true}\" id='igp$this->{id}'>\n<a name='igp$this->{id}'></a>\n"; 
     291    $this->{footer} = "<span class='foswikiClear'></span></div></noautolink>"; 
     292    $this->{format} = "<a href='\$imageurl' class='igpThumbNail {origurl:\"\$origurl\"}' title='\$comment'><img src='\$thumburl' alt='\$name' /></a>" 
     293      unless defined $this->{format}; 
     294    $result = $this->renderFormatted(); 
     295  } elsif ($this->{format}) { 
    278296    $result = $this->renderFormatted(); 
    279297  } else { 
     
    333351    $result .= 
    334352      "<link rel='parent' href='". 
    335        Foswiki::Func::getScriptUrl($this->{web}, $this->{topic}, 'view'). 
     353       $this->{session}->getScriptUrl(0, 'view', $this->{web}, $this->{topic}). 
    336354      "' title='Thumbnails' />\n"; 
    337355    if ($firstImg && $firstImg->{name} ne $filename) { 
    338356      $result .= 
    339357        "<link rel='first' href='". 
    340         Foswiki::Func::getScriptUrl($this->{web}, $this->{topic}, 'view', 
     358        $this->{session}->getScriptUrl(0, 'view', $this->{web}, $this->{topic}, 
    341359          'id'=>$this->{id}, 
    342360          'filename'=>$firstImg->{name}, 
     
    347365      $result .= 
    348366          "<link rel='last' href='". 
    349           Foswiki::Func::getScriptUrl($this->{web}, $this->{topic}, 'view', 
     367          $this->{session}->getScriptUrl(0, 'view', $this->{web}, $this->{topic}, 
    350368            'id'=>$this->{id}, 
    351369            'filename'=>$lastImg->{name}, 
     
    356374      $result .= 
    357375          "<link rel='next' href='". 
    358           Foswiki::Func::getScriptUrl($this->{web}, $this->{topic}, 'view', 
     376          $this->{session}->getScriptUrl(0, 'view', $this->{web}, $this->{topic}, 
    359377            'id'=>$this->{id}, 
    360378            'filename'=>$nextImg->{name}, 
     
    365383      $result .= 
    366384        "<link rel='previous' href='". 
    367         Foswiki::Func::getScriptUrl($this->{web}, $this->{topic}, 'view', 
     385        $this->{session}->getScriptUrl(0, 'view', $this->{web}, $this->{topic}, 
    368386          'id'=>$this->{id}, 
    369387          'filename'=>$prevImg->{name}, 
     
    401419  if ($firstImg && $firstImg->{name} ne $filename) { 
    402420    $result .= "<a class='igpNaviFirst' title='go to first' href='". 
    403     Foswiki::Func::getScriptUrl($this->{web}, $this->{topic}, 'view', 
     421    $this->{session}->getScriptUrl(0, 'view', $this->{web}, $this->{topic}, 
    404422      'id'=>$this->{id}, 
    405423      'filename'=>$firstImg->{name}, 
     
    411429  if ($prevImg) { 
    412430    $result .= "<a class='igpNaviPrev' title='go to previous' href='". 
    413     Foswiki::Func::getScriptUrl($this->{web}, $this->{topic}, 'view', 
     431    $this->{session}->getScriptUrl(0, 'view', $this->{web}, $this->{topic}, 
    414432      'id'=>$this->{id}, 
    415433      'filename'=>$prevImg->{name}, 
     
    421439  if ($nextImg) { 
    422440    $result .= "<a class='igpNaviNext' title='go to next' href='". 
    423     Foswiki::Func::getScriptUrl($this->{web}, $this->{topic}, 'view', 
     441    $this->{session}->getScriptUrl(0, 'view', $this->{web}, $this->{topic}, 
    424442      'id'=>$this->{id}, 
    425443      'filename'=>$nextImg->{name}, 
     
    431449  if ($lastImg && $lastImg->{name} ne $filename) { 
    432450    $result .= "<a class='igpNaviLast' title='go to last' href='". 
    433     Foswiki::Func::getScriptUrl($this->{web}, $this->{topic}, 'view', 
     451    $this->{session}->getScriptUrl(0, 'view', $this->{web}, $this->{topic}, 
    434452      'id'=>$this->{id}, 
    435453      'filename'=>$lastImg->{name}, 
     
    440458  } 
    441459  $result .= "<a class='igpNaviDone' href='". 
    442     Foswiki::Func::getScriptUrl($this->{web},$this->{topic}, 'view', "#"=>"igp$this->{id}"). 
     460    $this->{session}->getScriptUrl(0, 'view', $this->{web},$this->{topic}, "#"=>"igp$this->{id}"). 
    443461    "'><span>done</span></a>"; 
    444462 
     
    823841    $format =~ s/\$web/$image->{IGP_web}/gos; 
    824842    $format =~ s/\$topic/$image->{IGP_topic}/gos; 
     843    $format =~ s/\$id/$this->{id}/gos; 
    825844 
    826845  } 
Note: See TracChangeset for help on using the changeset viewer.