wip
authorEugene Crosser <crosser@average.org>
Wed, 20 Aug 2008 16:05:21 +0000 (16:05 +0000)
committerEugene Crosser <crosser@average.org>
Wed, 20 Aug 2008 16:05:21 +0000 (16:05 +0000)
include/gallery.js
mkgallery.pl

index a45f1d10a3c3aacdf88f09135eb01df7fc699adc..40707fe1eb8afc94062155745280c5ecdf8fb896 100644 (file)
@@ -17,15 +17,15 @@ var showWindow = new Class({
                        zIndex: 2,
                        container: document.body,
                        onClick: $empty,
-               };
+               }
        },
 
        initialize: function(div,options){
-               this.setOptions(this.getOptions(), options);
+               this.setOptions(this.getOptions(), options)
 
-               this.options.container = $(this.options.container);
+               this.options.container = $(this.options.container)
 
-               this.div = $(div);
+               this.div = $(div)
                this.div.setStyles({
                        position: 'absolute',
                        left: '0px',
@@ -34,61 +34,81 @@ var showWindow = new Class({
                        zIndex: this.options.zIndex,
                        overflow: 'hidden',
                        display: 'none'
-               });
+               })
                this.div.addEvent('click', function(){
-                       this.options.onClick();
-               }.bind(this));
+                       this.options.onClick()
+               }.bind(this))
 
-               this.position();
+               this.position()
 
-               window.addEvent('resize', this.position.bind(this));
-               window.addEvent('scroll', this.position.bind(this));
+               window.addEvent('resize', this.position.bind(this))
+               window.addEvent('scroll', this.position.bind(this))
        },
 
        position: function(){
                if(this.options.container == document.body){
-                       var h = window.getHeight()+'px';
-                       var s = window.getScrollTop()+'px';
-                       this.div.setStyles({top: s, height: h});
+                       var h = window.getHeight()+'px'
+                       var s = window.getScrollTop()+'px'
+                       this.div.setStyles({top: s, height: h})
                }else{
-                       var myCoords = this.options.container.getCoordinates();
+                       var myCoords = this.options.container.getCoordinates()
                        this.div.setStyles({
                                top: myCoords.top+'px',
                                height: myCoords.height+'px',
                                left: myCoords.left+'px',
                                width: myCoords.width+'px'
-                       });
+                       })
                }
        },
 
        show: function(){
-               this.div.setStyles({display: 'block'});
+               this.div.setStyles({display: 'block'})
        },
 
        hide: function(){
-               this.div.setStyles({display: 'none'});
+               this.div.setStyles({display: 'none'})
        }
-});
-showWindow.implement(new Options);
+})
+showWindow.implement(new Options)
 
 /* Make overlay window and start slideshow */
-function run_slideshow(startid) {
- showwin.show();
- show.stop();
- if (startid < 0) {
-  show.play(0);
- } else {
-  show.play(startid);
-  show.stop();
+function showImage(id,doplay) {
+ var i=rimgs[id]
+ /* alert('show id='+id+' index='+i+' doplay='+doplay) */
+ showwin.show()
+ show.play(i)
+ if (!doplay) {
+  show.stop()
  }
- return false;
+ return false
 }
 
 /* Stop slideshow and return to index page */
-function stop_slideshow() {
- show.stop();
- showwin.hide();
- return false;
+function showStop() {
+ show.stop()
+ showwin.hide()
+ /*
+ var img = show.newImage.getElement('img');
+ if(img) {
+  alert('remove element: '+img.get('tag')+'.'+img.get('class')+
+   '#'+img.get('id')+' src='+img.get('src'))
+  img.dispose()
+ }
+
+ img = show.oldImage.getElement('img');
+ if(img) {
+  alert('remove element: '+img.get('tag')+'.'+img.get('class')+
+   '#'+img.get('id')+' src='+img.get('src'))
+  img.dispose()
+ }
+
+ show.imagesHolder.getElements('img').each(function(el){
+  alert('remove element: '+el.get('tag')+'.'+el.get('class')+'#'+el.get('id')+
+   ' src='+el.get('src'))
+  el.dispose()
+ })
+ */
+ return false
 }
 
 /* List of lists of img variations. Each image variation is a three-element  */
@@ -103,16 +123,33 @@ var vimgs=[]
  *  ...
  * ]
 */
+/* resolve string ID to index */
+var rimgs=[]
+
 /* Initialize everything, to be called on domready */
 function init_gallery() {
- $$('div.varimages').each(function(el){
+ $$('.conceal').each(function(el){
+  el.setStyle('display', 'none')
+ })
+ $$('a.infoBox').each(function(el){
+  var url=el.get('href')
+  el.set('href',url+'?conceal')
+ })
+ $$('a.showStart').each(function(el){
+  el.addEvent('click', showImage.bind(el,[el.get('id'),1]))
+ })
+ $$('a.showImage').each(function(el){
+  el.addEvent('click', showImage.bind(el,[el.get('id'),0]))
+ })
+ $$('div.varimages').each(function(el,i){
   var id=el.id
-  vimgs[id]=[]
-  el.getElements('a').each(function(ael,i){
+  rimgs[id]=i
+  vimgs[i]=[]
+  el.getElements('a').each(function(ael,j){
    dim = /(\d+)[^\d](\d+)/.exec(ael.text)
    w = dim[1]
    h = dim[2]
-   vimgs[id][i]=[w,h,ael.href]
+   vimgs[i][j]=[w,h,ael.href]
   })
  })
    /* debugging output
@@ -147,16 +184,16 @@ function init_gallery() {
   wait: 3000,
   effect: 'fade',
   duration: 1000,
-  loop: true, 
+  loop: false, 
   thumbnails: true,
   onClick: function(i){alert(i)}
  }
  show = new slideShow('slideshowContainer','slideshowThumbnail',showparms)
 
  parsedurl = parseUrl(document.URL)
- // alert('Anchor: '+parsedurl['anchor']+'\nURL: '+document.URL)
+ /* alert('Anchor: '+parsedurl['anchor']+'\nURL: '+document.URL) */
  if ($chk(parsedurl['anchor'])){
-  run_slideshow(parsedurl['anchor'])
+  showImage(parsedurl['anchor'],0)
  }
 }
 
index 26e1729e3d11bddad9967ce68abe190cc9a905f1..0a4988c067899577d46b7a934da5c67dbd4c7bd2 100755 (executable)
@@ -398,7 +398,8 @@ sub makescaled {
                        $self->{$size}->{'dim'} = [$w, $h];
                } else {
                        $self->{$size}->{'url'} = $nref;
-                       $self->{$size}->{'dim'} = [$w*$factor, $h*$factor];
+                       $self->{$size}->{'dim'} = [int($w*$factor+.5),
+                                                       int($h*$factor+.5)];
                        if (isnewer($fn,$nfn)) {
                                doscaling($fn,$nfn,$factor,$w,$h);
                        }
@@ -451,7 +452,7 @@ sub makeaux {
        for my $refresh('static', 'slide') {
                my $fn = sprintf("%s/.html/%s-%s.html",$dn,$name,$refresh);
                if (isnewer($self->{-fullpath},$fn)) {
-                       my $imgsrc = '../'.$self->{$sizes[1]};
+                       my $imgsrc = '../'.$self->{$sizes[1]}->{'url'};
                        my $fwdref;
                        my $bakref;
                        if ($nref) {
@@ -496,18 +497,16 @@ sub makeaux {
                                        -style=>{-src=>$inc."gallery.css"},
                                        ),"\n";
                        }
-                       print $F start_center,"\n",
-                               h1($title),"\n",
-                               start_table({-class=>'navi'}),start_Tr,"\n",
+                       print $F start_table({-class=>'navi'}),start_Tr,"\n",
                                td(a({-href=>"../index.html"},"Index")),"\n",
                                td(a({-href=>$bakref},"&lt;&lt;Prev")),"\n",
                                td(a({-href=>$toggleref},$toggletext)),"\n",
                                td(a({-href=>$fwdref},"Next&gt;&gt;")),"\n",
+                               td({-class=>'title'},$title),"\n",
                                end_Tr,
                                end_table,"\n",
-                               table({-class=>'picframe'},
-                                       Tr(td(img({-src=>$imgsrc})))),"\n",
-                               end_center,"\n",
+                               center(table({-class=>'picframe'},
+                                       Tr(td(img({-src=>$imgsrc}))))),"\n",
                                end_html,"\n";
                        close($F);
                }
@@ -637,10 +636,9 @@ sub startimglist {
        my $first = $self->{-firstimg}->{-base};
        my $slideref = sprintf(".html/%s-slide.html",$first);
 
-       print $IND h2("Images"),"\n",
-               a({-href=>$slideref,
-                       -onClick=>"return run_slideshow(-1);"},
-                       'Slideshow'),
+       print $IND h2("Images ",
+               a({-href=>$slideref,-class=>'showStart',-id=>$first},
+                       '&gt; slideshow')),"\n",
                start_div({-id=>"slideshowWindow",-class=>"slideshowWindow"}),
                div({-id=>"slideshowContainer",
                        -class=>"slideshowContainer"},""),
@@ -654,7 +652,7 @@ sub startimglist {
                        "Stop"),
                a({-href=>"#",-onClick=>"show.next();return false;"},
                        "Next"),
-               a({-href=>"#",-onClick=>"stop_slideshow();return false;"},
+               a({-href=>"#",-onClick=>"showStop();return false;"},
                        "Exit"),
                end_div,
                end_div,
@@ -674,31 +672,33 @@ sub img_entry {
        my $i=0+$self->{-parent}->{-numofimgs};
        $self->{-parent}->{-numofimgs}++;
 
-       print $IND a({-name=>$i}),"\n",
+       print $IND a({-name=>$name}),"\n",
                start_table({-class=>'slide'}),start_Tr,start_td,"\n",
                div({-class=>'slidetitle',-id=>$name},
-                       a({-href=>".html/$name-info.html?conceal",
+                       "\n ",a({-href=>".html/$name-info.html",
                                -title=>'Image Info: '.$name,
                                -class=>'infoBox'},
-                               $title)),"\n",
+                               $title),"\n"),"\n",
                div({-class=>'slideimage',-id=>$name},
-                       a({-href=>".html/$name-static.html",-title=>$title,
-                               -id=>$name,
-                               -OnClick=>"return run_slideshow(".$i.");"},
-                               img({-src=>$thumb}))),"\n",
-               start_div({-class=>'varimages',-id=>$i});
+                       "\n ",a({-href=>".html/$name-static.html",
+                               -title=>$title,
+                               -class=>'showImage',
+                               -id=>$name},
+                               img({-src=>$thumb})),"\n"),"\n",
+               start_div({-class=>'varimages',-id=>$name}),"\n";
        foreach my $sz(@sizes) {
                my $src=$self->{$sz}->{'url'};
                my $w=$self->{$sz}->{'dim'}->[0];
                my $h=$self->{$sz}->{'dim'}->[1];
-               print $IND a({-href=>$src,-style=>"display: none;",
-                       -class=>($sz == 640)?"slideshowThumbnail":"",
+               print $IND "  ",a({-href=>$src,
+                       -class=>"conceal ".
+                               (($sz == 640)?"slideshowThumbnail":""),
                        -title=>"Reduced to ".$w."x".$h},
-                       $w."x".$h)," ";
+                       $w."x".$h)," \n";
        }
-       print $IND a({-href=>$name,
+       print $IND "  ",a({-href=>$name,
                                -title=>'Original'},$w."x".$h),
-               end_div,"\n",
+               "\n",end_div,"\n",
                end_td,end_Tr,end_table,"\n";
 }