It is currently Sun Apr 28, 2024 2:44 pm

All times are UTC




Post new topic Reply to topic  [ 29 posts ]  Go to page 1, 2  Next
Author Message
 Post Post subject: 100% JavaScript Gallery
 
Offline
Godlike Poster
Godlike Poster
Years of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membership
User avatar

Joined: Sun Oct 16, 2005 9:42 am
Posts: 8798
Karma: 17

Location: Imagine in your mind a posh country club
Steam Login Name: azcn2503
I made this in my spare time...

It's really good :)

I was never able to get this working years back when I was really in to my programming, but I managed to finally do it today.

If you'd like to see it in action I can post the code.

New version available on webtagr: http://www.webtagr.com/projects/gallery/gallery4.html

_________________
Follow your heart and live the dream <3


Last edited by azcn2503 on Tue Jul 12, 2011 8:02 am, edited 1 time in total.

Fri Jul 09, 2010 10:59 am 
 Profile E-mail  
 
 Post Post subject: Re: 100% JavaScript Gallery
 
Offline
Top Gun (Admin)
Top Gun (Admin)
Years of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membership
User avatar

Joined: Mon Sep 12, 2005 6:48 am
Posts: 23428
Karma: 11

Location: This forum.
Steam Login Name: Skillers1990
It would be nice to see :P

_________________
I was getting bored of this sig, and I realised I actually prefer small sigs ><
Join us on IRC! | TheSkillers.co.uk is under construction (still)!
Games: Steam | XFire | GFWL


Fri Jul 09, 2010 11:11 am 
 Profile  
 
 Post Post subject: Re: 100% JavaScript Gallery
 
Offline
Godlike Poster
Godlike Poster
Years of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membership
User avatar

Joined: Sun Oct 16, 2005 9:42 am
Posts: 8798
Karma: 17

Location: Imagine in your mind a posh country club
Steam Login Name: azcn2503
It's part of a larger site, but here is the code:

Code:
// Gallery :) 100% made by Aaron Cunnington <<< pride

// Change the array below to use your own images
var pics=[
   ["Image 1","image1.jpg"],
   ["Image 2","image1.jpg"],
   ["Image 3","image1.jpg"],
   ["Image 4","image1.jpg"],
   ["Image 5","image1.jpg"],
   ["Image 6","image1.jpg"],
   ["Image 7","image1.jpg"],
   ["Image 8","image1.jpg"],
   ["Image 9","image1.jpg"],
   ["Image 10","image1.jpg"],
   ["Image 11","image1.jpg"],
   ["Image 12","image1.jpg"],
   ["Image 13","image1.jpg"],
   ["Image 14","image1.jpg"],
   ["Image 15","image1.jpg"],
   ["Image 16","image1.jpg"],
   ["Image 17","image1.jpg"],
   ["Image 18","image1.jpg"],
   ["Image 19","image1.jpg"],
   ["Image 20","image1.jpg"],
   ["Image 21","image1.jpg"],
   ["Image 22","image1.jpg"],
   ["Image 23","image1.jpg"],
   ["Image 24","image1.jpg"],
   ["Image 25","image1.jpg"],
   ["Image 26","image1.jpg"],
   ["Image 27","image1.jpg"],
   ["Image 28","image1.jpg"],
   ["Image 29","image1.jpg"],
   ["Image 30","image1.jpg"],
   ["Image 31","image1.jpg"],
   ["Image 32","image1.jpg"],
   ["The last picture","image1.jpg"]
];
// Change the array above to use your own images

// Change the values below to change your gallery table layout
var galleryCells=4;
var galleryRows=3;
// Change the values above to change your gallery table layout

// ### DO NOT CHANGE ANYTHING BELOW THIS POINT
var galleryCellWidth=Math.floor(100/galleryCells);
var galleryStartRow=0;
var galleryPages=Math.floor(pics.length/(galleryCells*galleryRows))+1;
var galleryPagesText="";
for(var i=0;i<galleryPages;i++){
   galleryPagesText+=" <a href=\"javascript:galleryChangePage('goto',"+(i*(galleryCells*galleryRows))+");\">"+(i+1)+"</a> ";
   galleryPagesText+=i<galleryPages-1?"| ":"";
}

function writeGalleryTable(){
   document.write("<table id=\"gallerytable\">");
   for(var i=0;i<pics.length;i+=galleryCells){
      var rowClass=i>=galleryCells*galleryRows?"hidden":"active";
      // pic
      document.write("<tr class=\""+rowClass+"\" id=\"gallery_pic_row_"+i+"\">");
      for(var j=0;j<galleryCells;j++){
         var n=i+j;
         var picContent=pics[n]?"<img src=\"blue-fade3.jpg\" style=\"width:100%;\" />":"Sorry!";
         var capContent=pics[n]?pics[n][0]:"Nothing here!";
         document.write("<td class=\"pic\" style=\"width:"+galleryCellWidth+"%;\">"+picContent+"
"+capContent+"</td>");
      }
      document.write("</tr>");
   }
   document.write("<tr><td colspan=\""+galleryCells+"\" class=\"nav\"><div style=\"float:left;\"><a href=\"javascript:galleryChangePage('prev',0);\">Back</a></div>"+galleryPagesText+"<div style=\"float:right;\"><a href=\"javascript:galleryChangePage('next',0);\">Next</a></div></td></tr>");
   document.write("</table>");
}
function galleryChangePage(t,n){
   switch(t){
      case "next": galleryStartRow=galleryStartRow+(galleryCells*galleryRows)>=pics.length?galleryStartRow:galleryStartRow+(galleryCells*galleryRows); break;
      case "prev": galleryStartRow=galleryStartRow-(galleryCells*galleryRows)<0?galleryStartRow:galleryStartRow-(galleryCells*galleryRows); break;
      case "goto": galleryStartRow=n; break;
   }
   var galleryTable=grab("gallerytable");
   var galleryTableRows=galleryTable.getElementsByTagName("tr");
   for(i in galleryTableRows){
      if(galleryTableRows[i].id){
         if(galleryTableRows[i].id.indexOf("gallery_pic_row_")>=0){
            var thisRow=galleryTableRows[i].id.split("gallery_pic_row_")[1];
            grab("gallery_pic_row_"+thisRow).className=thisRow<galleryStartRow?"hidden":thisRow>=galleryStartRow+(galleryCells*galleryRows)?"hidden":"active";
         }
      }
   }
}

_________________
Follow your heart and live the dream <3


Fri Jul 09, 2010 11:41 am 
 Profile E-mail  
 
 Post Post subject: Re: 100% JavaScript Gallery
 
Offline
Godlike Poster
Godlike Poster
Years of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membership
User avatar

Joined: Sun Oct 16, 2005 9:42 am
Posts: 8798
Karma: 17

Location: Imagine in your mind a posh country club
Steam Login Name: azcn2503

Watch this video on Youtube.

_________________
Follow your heart and live the dream <3


Fri Jul 09, 2010 11:44 am 
 Profile E-mail  
 
 Post Post subject: Re: 100% JavaScript Gallery
 
Offline
Top Gun (Admin)
Top Gun (Admin)
Years of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membership
User avatar

Joined: Mon Sep 12, 2005 6:48 am
Posts: 23428
Karma: 11

Location: This forum.
Steam Login Name: Skillers1990
That's really quite awesome.

_________________
I was getting bored of this sig, and I realised I actually prefer small sigs ><
Join us on IRC! | TheSkillers.co.uk is under construction (still)!
Games: Steam | XFire | GFWL


Fri Jul 09, 2010 12:04 pm 
 Profile  
 
 Post Post subject: Re: 100% JavaScript Gallery
 
Offline
Godlike Poster
Godlike Poster
Years of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membership
User avatar

Joined: Sun Oct 16, 2005 9:42 am
Posts: 8798
Karma: 17

Location: Imagine in your mind a posh country club
Steam Login Name: azcn2503
Glad you like :)

Little extra:


Watch this video on Youtube.

_________________
Follow your heart and live the dream <3


Fri Jul 09, 2010 12:06 pm 
 Profile E-mail  
 
 Post Post subject: Re: 100% JavaScript Gallery
 
Offline
Godlike Poster
Godlike Poster
Years of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membership
User avatar

Joined: Sun Oct 16, 2005 9:42 am
Posts: 8798
Karma: 17

Location: Imagine in your mind a posh country club
Steam Login Name: azcn2503
Works on iPhone lol

Image

_________________
Follow your heart and live the dream <3


Sun Jul 11, 2010 12:53 pm 
 Profile E-mail  
 
 Post Post subject: Re: 100% JavaScript Gallery
 
Offline
Malevolent Artificial Intelligence
Malevolent Artificial Intelligence
Years of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membership
User avatar

Joined: Wed Sep 14, 2005 3:37 pm
Posts: 6434
Karma: 4
Wow that's brilliant! :D

Very nice work. :)


Clearly I need to learn some Javascript if I want to do awesome stuff like that. :P

_________________
In which the unthinkable happened.
Image
Signature created by schlürbi. :D


Sun Jul 11, 2010 2:21 pm 
 Profile E-mail  
 
 Post Post subject: Re: 100% JavaScript Gallery
 
Offline
Monster Poster
Monster Poster
Years of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membership

Joined: Tue Jun 02, 2009 3:23 pm
Posts: 733
Karma: -19

Steam Login Name: BartmanTaz
Pretty good actually.

_________________
Techious Star Community Member 2009/2010.

Voted for and funded by Scottie UK Ltd.


Tue Jul 13, 2010 10:03 am 
 Profile E-mail  
 
 Post Post subject: Re: 100% JavaScript Gallery
 
Offline
Godlike Poster
Godlike Poster
Years of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membership
User avatar

Joined: Sun Oct 16, 2005 9:42 am
Posts: 8798
Karma: 17

Location: Imagine in your mind a posh country club
Steam Login Name: azcn2503
Updated

Spoiler:
Code:
// Gallery :) 100% made by Aaron Cunnington <<< pride

// Change the array below to use your own images
var pics=[
   ["Image 1","image1.jpg"],
   ["Image 2","image1.jpg"],
   ["Image 3","image1.jpg"],
   ["Image 4","image1.jpg"],
   ["Image 5","image1.jpg"],
   ["Image 6","image1.jpg"],
   ["Image 7","image1.jpg"],
   ["Image 8","image1.jpg"],
   ["Image 9","image1.jpg"],
   ["Image 10","image1.jpg"],
   ["Image 11","image1.jpg"],
   ["Image 12","image1.jpg"],
   ["Image 13","image1.jpg"],
   ["Image 14","image1.jpg"],
   ["Image 15","image1.jpg"],
   ["Image 16","image1.jpg"],
   ["Image 17","image1.jpg"],
   ["Image 18","image1.jpg"],
   ["Image 19","image1.jpg"],
   ["Image 20","image1.jpg"],
   ["Image 21","image1.jpg"],
   ["Image 22","image1.jpg"],
   ["Image 23","image1.jpg"],
   ["Image 24","image1.jpg"],
   ["Image 25","image1.jpg"],
   ["Image 26","image1.jpg"],
   ["Image 27","image1.jpg"],
   ["Image 28","image1.jpg"],
   ["Image 29","image1.jpg"],
   ["Image 30","image1.jpg"]
];
// Change the array above to use your own images



// Change the values below to change your gallery table layout

var galleryCells=4; // number of cells per row
var galleryRows=3; // number of rows per page

var thumbWidth=50; // 0 = auto/browser
var thumbWidthType="px"; // 0 = px
var thumbHeight=0; // 0 = auto/browser
var thumbHeightType=0; // 0 = px

// Change the values above to change your gallery table layout



// ### DO NOT CHANGE ANYTHING BELOW THIS POINT
var galleryGrid=galleryCells*galleryRows;
var galleryCellWidth=Math.floor(100/galleryCells);
var galleryStartRow=0; // used as a counter
var galleryPages=Math.floor(pics.length/galleryGrid);
galleryPages+=pics.length%galleryGrid==0?0:1;
var galleryPagesText="";
for(var i=0;i<galleryPages;i++){
   galleryPagesText+="<a id=\"gallery_page_link_"+(i*galleryGrid)+"\" class=\"normal\" href=\"javascript:galleryChangePage('goto',"+(i*galleryGrid)+");\">"+(i+1)+"</a>";
   // galleryPagesText+=i<galleryPages-1?" | ":"";
}
var totalCells=galleryPages*galleryGrid;
var thumbWidthText="width:"+(thumbWidth==0?"auto":thumbWidth)+(thumbWidth==0?"":thumbWidthType==0?"px":thumbWidthType);
var thumbHeightText="height:"+(thumbHeight==0?"auto":thumbHeight)+(thumbHeight==0?"":thumbHeightType==0?"px":thumbHeightType);

function writeGalleryTable(){
   document.write("<table id=\"gallerytable\">");
   for(var i=0;i<totalCells;i+=galleryCells){
      var rowClass=i>=galleryGrid?"hidden":"active";
      // pic
      document.write("<tr class=\""+rowClass+"\" id=\"gallery_pic_row_"+i+"\">");
      for(var j=0;j<galleryCells;j++){
         var n=i+j;
         var picContent=pics[n]?"<img src=\"tchslogo.jpg\" style=\""+thumbWidthText+";"+thumbHeightText+"\" />":"<img src=\"tchslogo.jpg\" style=\""+thumbWidthText+";"+thumbHeightText+"\" class=\"invis\" />";
         var capContent=pics[n]?pics[n][0]:"&nbsp;";
         document.write("<td class=\"pic\" style=\"width:"+galleryCellWidth+"%;\">"+picContent+"
"+capContent+"</td>");
      }
      document.write("</tr>");
   }
   document.write("<tr><td colspan=\""+galleryCells+"\" class=\"nav\"><div style=\"float:left;\"><a href=\"javascript:galleryChangePage('prev',0);\">Back</a></div>"+galleryPagesText+"<div style=\"float:right;\"><a href=\"javascript:galleryChangePage('next',0);\">Next</a></div></td></tr>");
   document.write("</table>");
}
function galleryChangePage(t,n){
   switch(t){
      case "next": galleryStartRow=galleryStartRow+galleryGrid>=pics.length?galleryStartRow:galleryStartRow+galleryGrid; break;
      case "prev": galleryStartRow=galleryStartRow-galleryGrid<0?galleryStartRow:galleryStartRow-galleryGrid; break;
      case "goto": galleryStartRow=n; break;
   }
   for(var i=0;i<pics.length;i+=galleryGrid){
      grab("gallery_page_link_"+i).className=i==galleryStartRow?"active":"normal";
   }
   var galleryTable=grab("gallerytable");
   var galleryTableRows=galleryTable.getElementsByTagName("tr");
   for(i in galleryTableRows){
      if(galleryTableRows[i].id){
         if(galleryTableRows[i].id.indexOf("gallery_pic_row_")>=0){
            var thisRow=galleryTableRows[i].id.split("gallery_pic_row_")[1];
            grab("gallery_pic_row_"+thisRow).className=thisRow<galleryStartRow?"hidden":thisRow>=galleryStartRow+galleryGrid?"hidden":"active";
         }
      }
   }
}


You do not have the required permissions to view the files attached to this post.

_________________
Follow your heart and live the dream <3


Tue Jul 13, 2010 11:38 am 
 Profile E-mail  
 
 Post Post subject: Re: 100% JavaScript Gallery
 
Offline
Godlike Poster
Godlike Poster
Years of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membership
User avatar

Joined: Sun Oct 16, 2005 9:42 am
Posts: 8798
Karma: 17

Location: Imagine in your mind a posh country club
Steam Login Name: azcn2503
I don't know why I never posted the most recent version of this gallery file... to think it had been stuck on my work PC this whole time.

I wanted to use the above code for a friend, and realised... I couldn't click the pictures to make them larger. I remembered making this change a while back. I found it in a folder on my local server thankfully...

Here is the new code:

Spoiler:
Code:
// Gallery :) 100% made by Aaron Cunnington <<< pride
// Improved for Ania <3

// Change the array below to use your own images
var pics=[
    ["Image 1","smiley.png"],
    ["Image 2","smiley.png"],
    ["Image 3","smiley.png"],
    ["Image 4","smiley.png"],
    ["Image 5","smiley.png"],
    ["Image 6","smiley.png"],
    ["Image 7","smiley.png"],
    ["Image 8","smiley.png"],
    ["Image 9","smiley.png"],
    ["Image 10","smiley.png"],
    ["Image 11","smiley.png"],
    ["Image 12","smiley.png"],
    ["Image 13","smiley.png"],
    ["Image 14","smiley.png"],
    ["Image 15","smiley.png"],
    ["Image 16","smiley.png"],
    ["Image 17","smiley.png"],
    ["Image 18","smiley.png"],
    ["Image 19","smiley.png"],
    ["Image 20","smiley.png"],
    ["Image 21","smiley.png"],
    ["Image 22","smiley.png"],
    ["Image 23","smiley.png"],
    ["Image 24","smiley.png"]
];
// Change the array above to use your own images



// Change the values below to change your gallery table layout

var galleryCells=4; // number of cells per row
var galleryRows=3; // number of rows per page

var thumbWidth=100; // 0 = auto/browser
var thumbWidthType=0; // 0 = px
var thumbHeight=0; // 0 = auto/browser
var thumbHeightType=0; // 0 = px

// Change the values above to change your gallery table layout



// ### DO NOT CHANGE ANYTHING BELOW THIS POINT
var galleryGrid=galleryCells*galleryRows;
var galleryCellWidth=Math.floor(100/galleryCells);
var galleryStartRow=0; // used as a counter
var galleryPages=Math.floor(pics.length/galleryGrid);
galleryPages+=pics.length%galleryGrid===0?0:1;
var galleryPagesText="";
for(var i=0;i<galleryPages;i++){
    galleryPagesText+="<a id=\"gallery_page_link_"+(i*galleryGrid)+"\" class=\"normal\" href=\"javascript:galleryChangePage('goto',"+(i*galleryGrid)+");\">"+(i+1)+"</a>";
    // galleryPagesText+=i<galleryPages-1?" | ":"";
}
var totalCells=galleryPages*galleryGrid;
var thumbWidthText="width:"+(thumbWidth===0?"auto":thumbWidth)+(thumbWidth===0?"":thumbWidthType===0?"px":thumbWidthType);
var thumbHeightText="height:"+(thumbHeight===0?"auto":thumbHeight)+(thumbHeight===0?"":thumbHeightType===0?"px":thumbHeightType);

function writeGalleryTable(){
    document.write("<table id=\"gallerytable\">\n");
    for(var i=0;i<totalCells;i+=galleryCells){
        var rowClass=i>=galleryGrid?"hidden":"active";
        // pic
        document.write("<tr class=\""+rowClass+"\" id=\"gallery_pic_row_"+i+"\">\n");
        for(var j=0;j<galleryCells;j++){
            var n=i+j;
            var picContent=pics[n]?"<a href=\"javascript:doGalleryPicture('show',"+n+");\"><img src=\""+pics[n][1]+"\" style=\""+thumbWidthText+";"+thumbHeightText+"\" /></a>":"<img src=\"tchslogo.jpg\" style=\""+thumbWidthText+";"+thumbHeightText+"\" class=\"invis\" />";
            var capContent=pics[n]?pics[n][0]:"&nbsp;";
            document.write("<td class=\"pic\" style=\"width:"+galleryCellWidth+"%;\">"+picContent+"
"+capContent+"</td>\n");
        }
        document.write("</tr>\n");
    }
    document.write("<tr>\n<td colspan=\""+galleryCells+"\" class=\"nav\">\n<div style=\"float:left;\"><a href=\"javascript:galleryChangePage('prev',0);\">Back</a></div>\n<div style=\"float:left;\">"+galleryPagesText+"</div>\n<div style=\"float:right;\"><a href=\"javascript:galleryChangePage('next',0);\">Next</a></div>\n</td>\n</tr>\n");
    document.write("</table>\n");
}
function galleryChangePage(t,n){
    switch(t){
        case "next": galleryStartRow=galleryStartRow+galleryGrid>=pics.length?galleryStartRow:galleryStartRow+galleryGrid; break;
        case "prev": galleryStartRow=galleryStartRow-galleryGrid<0?galleryStartRow:galleryStartRow-galleryGrid; break;
        case "goto": galleryStartRow=n; break;
    }
    for(var i=0;i<pics.length;i+=galleryGrid){
        grab("gallery_page_link_"+i).className=i==galleryStartRow?"active":"normal";
    }
    var galleryTable=grab("gallerytable");
    var galleryTableRows=galleryTable.getElementsByTagName("tr");
    for(i in galleryTableRows){
        if(galleryTableRows[i].id){
            if(galleryTableRows[i].id.indexOf("gallery_pic_row_")>=0){
                var thisRow=galleryTableRows[i].id.split("gallery_pic_row_")[1];
                grab("gallery_pic_row_"+thisRow).className=thisRow<galleryStartRow?"hidden":thisRow>=galleryStartRow+galleryGrid?"hidden":"active";
            }
        }
    }
}
function doGalleryPicture(t,n){
    var sectionParent=grab("gallerytable").parentNode.id;
    switch(t){
        case "show":
            if(pics[n]){
                var singlePic=document.createElement("div");
                // singlePic.setAttribute("id","galleryPic_"+n);
                singlePic.id="galleryPic_"+n;
                // singlePic.setAttribute("class","gallerypic");
                singlePic.className="gallerypic";
                singlePic.innerHTML="<div class=\"content\"><p class=\"title\">"+pics[n][0]+"</p><p><img src=\""+pics[n][1]+"\" /></p><p><a href=\"javascript:doGalleryPicture('hide',"+n+");\">Back</a></div>";
                grab("gallerytable").className="hidden";
                grab(sectionParent).appendChild(singlePic);
            }
        break;
        case "hide":
            if(grab("galleryPic_"+n)){
                grab(sectionParent).removeChild(grab("galleryPic_"+n));
                grab("gallerytable").className="active";
            }
        break;
    }
}


And here's a link to the page it's being used on (it may disappear without warning): http://www.shinelikeastars.com/test.php ... ccessories

_________________
Follow your heart and live the dream <3


Thu Dec 30, 2010 10:41 am 
 Profile E-mail  
 
 Post Post subject: Re: 100% JavaScript Gallery
 
Offline
Godlike Poster
Godlike Poster
Years of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membership
User avatar

Joined: Sun Oct 16, 2005 9:42 am
Posts: 8798
Karma: 17

Location: Imagine in your mind a posh country club
Steam Login Name: azcn2503
I am revisiting this code again and updating it to be more object based and to completely remove all noob code from it. As part of this, I will be adding gallery categories. Eventually, it will be used on the new GVKF website (www.gvkf.org.uk)

_________________
Follow your heart and live the dream <3


Thu Jul 07, 2011 3:37 pm 
 Profile E-mail  
 
 Post Post subject: Re: 100% JavaScript Gallery
 
Offline
Top Gun (Admin)
Top Gun (Admin)
Years of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membership
User avatar

Joined: Mon Sep 12, 2005 6:48 am
Posts: 23428
Karma: 11

Location: This forum.
Steam Login Name: Skillers1990
You seem to be taking a lot of web development on atm, Aaron.

_________________
I was getting bored of this sig, and I realised I actually prefer small sigs ><
Join us on IRC! | TheSkillers.co.uk is under construction (still)!
Games: Steam | XFire | GFWL


Thu Jul 07, 2011 5:14 pm 
 Profile  
 
 Post Post subject: Re: 100% JavaScript Gallery
 
Offline
Godlike Poster
Godlike Poster
Years of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membership
User avatar

Joined: Sun Oct 16, 2005 9:42 am
Posts: 8798
Karma: 17

Location: Imagine in your mind a posh country club
Steam Login Name: azcn2503
I've been really lucky :) it has been fun to work with these people. It seems that one thing very quickly leads to another. This is a very good thing :)

_________________
Follow your heart and live the dream <3


Thu Jul 07, 2011 7:14 pm 
 Profile E-mail  
 
 Post Post subject: Re: 100% JavaScript Gallery
 
Offline
Top Gun (Admin)
Top Gun (Admin)
Years of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membership
User avatar

Joined: Mon Sep 12, 2005 6:48 am
Posts: 23428
Karma: 11

Location: This forum.
Steam Login Name: Skillers1990
Awesome! Sounds good, and I presume a nice bit of extra money aswell.

_________________
I was getting bored of this sig, and I realised I actually prefer small sigs ><
Join us on IRC! | TheSkillers.co.uk is under construction (still)!
Games: Steam | XFire | GFWL


Thu Jul 07, 2011 9:19 pm 
 Profile  
 
 Post Post subject: Re: 100% JavaScript Gallery
 
Offline
Godlike Poster
Godlike Poster
Years of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membership
User avatar

Joined: Sun Oct 16, 2005 9:42 am
Posts: 8798
Karma: 17

Location: Imagine in your mind a posh country club
Steam Login Name: azcn2503
That's it :)

Anyway. This is what I have been working on today: http://www.webtagr.com/projects/gallery/gallery4.html

_________________
Follow your heart and live the dream <3


Fri Jul 08, 2011 11:02 pm 
 Profile E-mail  
 
 Post Post subject: Re: 100% JavaScript Gallery
 
Offline
Godlike Poster
Godlike Poster
Years of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membership
User avatar

Joined: Sun Oct 16, 2005 9:42 am
Posts: 8798
Karma: 17

Location: Imagine in your mind a posh country club
Steam Login Name: azcn2503
Updated this, let me know what you think. Still a lot of work to do on it as you can see.

_________________
Follow your heart and live the dream <3


Sun Jul 10, 2011 10:51 am 
 Profile E-mail  
 
 Post Post subject: Re: 100% JavaScript Gallery
 
Offline
Unstoppable
Unstoppable
Years of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membership

Joined: Sun Nov 15, 2009 8:40 pm
Posts: 1038
Karma: 10
Clicking the image sets the <title> as the description?
Looks pretty nice though :D

_________________
Skillers wrote:
Oh gawd no! Not the crazy frog! Arghhhhhh! $&^%&*^%*&#$^ %$(%^((% %$(O*%(#*%^ %)*#$&%)*@#% %_(#&%*%) frog


Sun Jul 10, 2011 10:58 am 
 Profile E-mail  
 
 Post Post subject: Re: 100% JavaScript Gallery
 
Offline
Godlike Poster
Godlike Poster
Years of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membership
User avatar

Joined: Sun Oct 16, 2005 9:42 am
Posts: 8798
Karma: 17

Location: Imagine in your mind a posh country club
Steam Login Name: azcn2503
Yeah :) Just changed it again... I made a mistake in the code that made paging break when more than 1 row of pictures were being displayed at a time.
There is a second problem that affects the layout but is not visible at the moment. Additional rows of blank cells are not wrote to the page causing the size of the gallery to change massively. If I chose to display a 3x3 table, it would display 3 rows on the first page and only 1 on the second page, and with each row being over 200 pixels high it makes a huge difference on the screen. Looks odd. Will fix!

_________________
Follow your heart and live the dream <3


Sun Jul 10, 2011 11:19 am 
 Profile E-mail  
 
 Post Post subject: Re: 100% JavaScript Gallery
 
Offline
Godlike Poster
Godlike Poster
Years of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membership
User avatar

Joined: Sun Oct 16, 2005 9:42 am
Posts: 8798
Karma: 17

Location: Imagine in your mind a posh country club
Steam Login Name: azcn2503
Fixed.

_________________
Follow your heart and live the dream <3


Sun Jul 10, 2011 11:57 am 
 Profile E-mail  
 
 Post Post subject: Re: 100% JavaScript Gallery
 
Offline
Godlike Poster
Godlike Poster
Years of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membership
User avatar

Joined: Sun Oct 16, 2005 9:42 am
Posts: 8798
Karma: 17

Location: Imagine in your mind a posh country club
Steam Login Name: azcn2503
OK. I need your advice...

What would be the best way to make the full size image appear on-screen?

The problem I am facing is this...

To make an image appear horizontally and vertically centred, I need make the image inside a container because only elements that are styled with display:table-cell use the vertical-align:center style as expected (in the same way the old HTML valign="center" worked) - sounds cool right? Why not do it, right? Well, here lies the problem... every area inside and outside of the image is a part of the parent element.

Actually. I'm going to stop here. I've worked out a fix already. Back in an hour.

Update: Updated.
Also, paging doesn't work in IE. Cannot find out why...
Asked IE to alert className of object before and after paging, and it changes. However, nothing updates on page, style does not apply, rows do not hide/display. No JS errors. Works in all other browsers.

_________________
Follow your heart and live the dream <3


Sun Jul 10, 2011 8:23 pm 
 Profile E-mail  
 
 Post Post subject: Re: 100% JavaScript Gallery
 
Offline
Godlike Poster
Godlike Poster
Years of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membership
User avatar

Joined: Sun Oct 16, 2005 9:42 am
Posts: 8798
Karma: 17

Location: Imagine in your mind a posh country club
Steam Login Name: azcn2503
Here is the beautifully uncommented code:

Code:
gallery=[
    {
        title:"Gallery of Win",
        description:"A really cool gallery",
        contents:[
            {
                image:"gallery4/image1.jpg",
                thumb:"gallery4/test1.jpg",
                title:"Zoe",
                description:"A lovely picture of Zoe!",
                hide:false
            },
            {
                image:"gallery4/image2.jpg",
                thumb:"gallery4/test2.jpg",
                title:"Jet",
                description:"A lovely picture of Jet!",
                hide:false
            },
            {
                image:"gallery4/image3.jpg",
                thumb:"gallery4/test3.jpg",
                title:"Zoe",
                description:"A lovely picture of Zoe!",
                hide:false
            },
            {
                image:"gallery4/image4.jpg",
                thumb:"gallery4/test4.jpg",
                title:"Zoe and Friend",
                description:"A lovely picture of Zoe with her friend!",
                hide:false
            },
            {
                image:"gallery4/image5.jpg",
                thumb:"gallery4/test5.jpg",
                title:"Zoe and Friend",
                description:"A lovely picture of Zoe with her friend!",
                hide:false
            },
            {
                image:"gallery4/image6.jpg",
                thumb:"gallery4/test6.jpg",
                title:"Zoe",
                description:"A lovely picture of Zoe!",
                hide:false
            },
            {
                image:"gallery4/image7.jpg",
                thumb:"gallery4/test7.jpg",
                title:"Zoe",
                description:"A lovely picture of Zoe!"
            },
            {
                image:"gallery4/image8.jpg",
                thumb:"gallery4/test8.jpg",
                title:"Zoe",
                description:"A lovely picture of Zoe!"
            },
            {
                image:"gallery4/image9.jpg",
                thumb:"gallery4/test9.jpg",
                title:"Zoe",
                description:"A lovely picture of Zoe!"
            },
            {
                image:"gallery4/image10.jpg",
                thumb:"gallery4/test10.jpg",
                title:"Zoe",
                description:"A lovely picture of Zoe!"
            },
            {
                image:"gallery4/image11.jpg",
                thumb:"gallery4/test11.jpg",
                title:"Zoe",
                description:"A lovely picture of Zoe!"
            }
        ]
    },
    {
        title:"Test Gallery",
        description:"Pretty much the same as the last gallery, but not!",
        contents:[
            {
                image:"test.jpg",
                thumb:"gallery4/test1.jpg",
                title:"Testing!",
                description:"As you can see, I am testing!"
            },
            {
                image:"test.jpg",
                thumb:"gallery4/test1.jpg",
                title:"Testing!",
                description:"As you can see, I am testing!"
            },
            {
                image:"test.jpg",
                thumb:"gallery4/test1.jpg",
                title:"Testing!",
                description:"As you can see, I am testing!"
            },
            {
                image:"test.jpg",
                thumb:"gallery4/test1.jpg",
                title:"Testing!",
                description:"As you can see, I am testing!"
            }
        ]
    },
    {
        title:"Geek Porn",
        description:"Some stuff",
        contents:[
            {
                image:"gallery4/GX-198-XF_400.jpg",
                thumb:"gallery4/GX-198-XF_200_thumb.jpg",
                title:"Radeon 6990",
                description:"XFX ATI Radeon 6990 4GB GDDR5 PCI-Express"
            }
        ]
    }
];
var galleryAjaxMode=false;
var galleryIDPrefix="gallery";
var goverlayhover=false;
var goverlaymode=1;
var gpreloadimg=new Image();
var gpreloadpics=[];
var gpageprefix="Page ";
var thumbWidth=100;
var thumbWidthType="%";
var thumbHeight=100;
var thumbHeightType="%";
function galleryGrab(o){
    return document.all?document.all[o]:document.getElementById?document.getElementById(o):"";
}
function galleryAdd(os,gt,gc,gr,tm,pm,aj){
    !gc?gc=4:gc;
    !gr?gr=3:gr;
    if(tm==null||tm=="undefined"){ tm=true; }
    if(pm==null||pm=="undefined"){ pm=true; }
    if(aj==null||aj=="undefined"){ aj=false; }
    var o=galleryGrab(os);
    var gg=gc*gr;
    var gcw=Math.floor(100/gc);
    var pages=false;
    for(var i in gallery){
        if(gallery[i].hasOwnProperty("title")){
            if(gallery[i].title==gt){
                var cg=gallery[i].contents;
                var gA=[];
                for(var j in cg){ if(cg[j].hide===true){ } else{ gA.push([cg[j],j]); } }
                var gl=gA.length;
                var gp=Math.floor(gl/gg);
                    gp+=gl%gg===0?0:1;
                var _shade=document.createElement("div");
                    _shade.id=i+"shade";
                    _shade.className="gshade gdn";
                    _shade.onclick=function(){
                        if(goverlayhover==false||goverlaymode==1){
                            this.className="gshade gdn";
                        }
                    }
                    if(goverlaymode==0){
                        _shade.onmousemove=function(){
                            if(goverlayhover==false){
                                this.className="gshade gdt gshadehover";
                            }
                            else{
                                this.className="gshade gdt";
                            }
                        }
                    }
                    _shade.onselectstart=function(){ return false; };
                var _overlay=document.createElement("div");
                    _overlay.id=i+"overlay";
                    _overlay.className="goverlay gdtc";
                _shade.appendChild(_overlay);
                o.appendChild(_shade);
                if(tm===true){
                    var _tab=document.createElement("table");
                        _tab.className="gcontents";
                    var coverflow=gc-gl%gc;
                    var roverflow=gl%gr;
                    var lastj=0;
                    for(var j in gA){
                        var cg=gA[j];
                        if(document.images){
                            var plc=true;
                            for(var k in gpreloadpics){
                                if(gpreloadpics[k]==cg[0].image){ var plc=false; }
                            }
                            if(plc===true){ gpreloadpics.push(cg[0].image); }
                        }
                        if(j%gc==0){
                            var _row=document.createElement("tr");
                                _row.id=i+"&r"+j/gc;
                            if(j>=gg&&pm===true){ _row.className="grhidden"; }
                        }
                        var _cel=document.createElement("td");
                            _cel.id=i+"&g"+cg[1];
                            _cel.className="gcell";
                            _cel.onclick=function(){
                                var nA=this.id.split("&g");
                                galleryImagePreviewer([nA[0],gallery[nA[0]].contents[nA[1]]]);
                            };
                            _cel.onselectstart=function(){ return false; }
                        var _img=document.createElement("img");
                            _img.src=cg[0].thumb;
                            _img.alt=cg[0].title;
                            _img.onmousedown=function(){ return false; }
                        var _cap=document.createElement("div");
                            _cap.className="caption";
                            _cap.innerHTML=cg[0].title;
                        _cel.appendChild(_img);
                        _cel.appendChild(_cap);
                        _row.appendChild(_cel);
                        if(j>=0&&j%gc==0){
                            _tab.appendChild(_row);
                        }
                        if(j>=gg){
                            if(!pages){
                                pages=true;
                            }
                        }
                        lastj++;
                    }
                    if(coverflow>0&&coverflow!=gc){
                        for(var j=0;j<coverflow;j++){
                            var _cel=document.createElement("td");
                                _cel.className="gcell";
                            var _img=document.createElement("img");
                                _img.src="gallery4/hidden.png";
                            _cel.appendChild(_img);
                            _row.appendChild(_cel);
                            lastj++;
                        }
                    }
                    if(pm===true&&roverflow>0){
                        for(var j=lastj;j<lastj+(roverflow*gc);j++){
                            if(j%gc==0){
                                var _row=document.createElement("tr");
                                    _row.id=i+"&r"+j/gc;
                                if(j>=gg&&pm===true){ _row.className="grhidden"; }
                            }
                            var _cel=document.createElement("td");
                                _cel.className="gcell";
                            var _wrapper=document.createElement("wrapper");
                                _wrapper.className="wrapper";
                            var _img=document.createElement("img");
                                _img.src="gallery4/hidden.png";
                                _img.onmousedown=function(){ return false; }
                            _wrapper.appendChild(_img);
                            var _cap=document.createElement("div");
                                _cap.className="caption";
                                _cap.innerHTML="&nbsp;";
                            _cel.appendChild(_wrapper);
                            _cel.appendChild(_cap);
                            _row.appendChild(_cel);
                            if(j>=0&&j%gc==0){
                                _tab.appendChild(_row);
                            }
                        }
                    }
                    if(pm===true&&pages){
                        var _prow=document.createElement("tr");
                        var _cel=document.createElement("td");
                            _cel.colSpan=gc;
                            _cel.className="gpages";
                        for(var j=0;j<gp;j++){
                            var _anc=document.createElement("div");
                                _anc.id=i+"&p"+j+"_"+gp+"_"+gr;
                                _anc.innerHTML=gpageprefix+(j+1);
                                _anc.className=j==0?"active":"inactive";
                                _anc.onclick=function(){
                                    var ps=this.id.split("&p");
                                    var gn=parseInt(ps[0]);
                                    var pn=parseInt(ps[1].split("_")[0]);
                                    var gp=parseInt(ps[1].split("_")[1]);
                                    var gr=parseInt(ps[1].split("_")[2]);
                                    alert("You requested page "+(pn+1));
                                    for(var i=0;i<gp;i++){
                                        alert("I am going to grab the paging tab with the following ID:\n"+gn+"&p"+i+"_"+gp+"_"+gr+" (Gallery "+gn+"; page "+(i+1)+" of "+(gp)+", has "+gr+" rows)\n\nI am going to change its className to the following:\n"+(pn==i?"active":"inactive"));
                                        galleryGrab(gn+"&p"+i+"_"+gp+"_"+gr).className=pn==i?"active":"inactive";
                                        alert("Paging tab "+gn+"&p"+i+"_"+gp+"_"+gr+" now has a className of:\n"+galleryGrab(gn+"&p"+i+"_"+gp+"_"+gr).className+" (I grabbed this objects className from the DOM)");
                                    }
                                    for(var i=0;i<gp*gr;i+=gr){
                                        for(var j=0;j<gr;j++){
                                            galleryGrab(gn+"&r"+(i+j)).className=pn==(i/gr)?"":"grhidden";
                                        }
                                    }
                                };
                            _cel.appendChild(_anc);
                        }
                        _prow.appendChild(_cel);
                        _tab.appendChild(_prow);
                    }
                    o.appendChild(_tab);
                }
                else{
                    var _gal=document.createElement("div");
                        _gal.className="gcontents";
                    for(var j in gA){
                        var cg=gA[j];
                        var _cel=document.createElement("div");
                            _cel.id=i+"&g"+cg[1];
                            _cel.className="gcell";
                            _cel.onclick=function(){
                                var nA=this.id.split("&g");
                                galleryImagePreviewer([nA[0],gallery[nA[0]].contents[nA[1]]]);
                            };
                            _cel.onselectstart=function(){ return false; };
                        var _img=document.createElement("img");
                            _img.src=cg[0].thumb;
                            _img.alt=cg[0].title;
                            _img.onmousedown=function(){ return false; };
                        var _cap=document.createElement("div");
                            _cap.className="caption";
                            _cap.innerHTML=cg[0].title;
                        _cel.appendChild(_img);
                        _cel.appendChild(_cap);
                        _gal.appendChild(_cel);
                    }
                    o.appendChild(_gal);
                }
            }
        }
    }
    galleryImagePreloader();
}
function galleryImagePreloader(){
    for(var i in gpreloadpics){
        gpreloadimg.src=gpreloadpics[i];
    }
}
function galleryImagePreviewer(args){
    galleryGrab(args[0]+"shade").className="gshade gdt";
    var _overlay=galleryGrab(args[0]+"overlay");
    var _cel=document.createElement("div");
        _cel.className="gcell";
        _cel.onmouseover=function(){ goverlayhover=true; }
        _cel.onmouseout=function(){ goverlayhover=false; }
    var _img=document.createElement("img");
        _img.src=args[1].image;
        _img.alt=args[1].title;
        _img.onmousedown=function(){ return false; };
        _img.onload=function(){
            var ml=getComputedWidth(this)-40;
        };
    var _cap=document.createElement("div");
        _cap.className="caption";
        _cap.innerHTML=args[1].title;
    var _sub=document.createElement("div");
        _sub.className="subcaption";
        _sub.innerHTML=args[1].description;
    _cel.appendChild(_img);
    _cel.appendChild(_cap);
    _cel.appendChild(_sub);
    _overlay.innerHTML="";
    _overlay.appendChild(_cel);
}


It doesn't work in any version of Internet Explorer. There seems to be no reason why, as it reports that it successfully changes the classNames of the paging tabs and the table rows. The classNames change the display type of the rows and the appearance of the paging tabs. Internet Explorer normally supports the changing of classNames without any issue. See if you can work out why it does not work...

In particular pay attention to these lines:

Code:
                                _anc.onclick=function(){
                                    var ps=this.id.split("&p");
                                    var gn=parseInt(ps[0]);
                                    var pn=parseInt(ps[1].split("_")[0]);
                                    var gp=parseInt(ps[1].split("_")[1]);
                                    var gr=parseInt(ps[1].split("_")[2]);
                                    alert("You requested page "+(pn+1));
                                    for(var i=0;i<gp;i++){
                                        alert("I am going to grab the paging tab with the following ID:\n"+gn+"&p"+i+"_"+gp+"_"+gr+" (Gallery "+gn+"; page "+(i+1)+" of "+(gp)+", has "+gr+" rows)\n\nI am going to change its className to the following:\n"+(pn==i?"active":"inactive"));
                                        galleryGrab(gn+"&p"+i+"_"+gp+"_"+gr).className=pn==i?"active":"inactive";
                                        alert("Paging tab "+gn+"&p"+i+"_"+gp+"_"+gr+" now has a className of:\n"+galleryGrab(gn+"&p"+i+"_"+gp+"_"+gr).className+" (I grabbed this objects className from the DOM)");
                                    }
                                    for(var i=0;i<gp*gr;i+=gr){
                                        for(var j=0;j<gr;j++){
                                            galleryGrab(gn+"&r"+(i+j)).className=pn==(i/gr)?"":"grhidden";
                                        }
                                    }
                                };

_________________
Follow your heart and live the dream <3


Wed Jul 13, 2011 5:15 pm 
 Profile E-mail  
 
 Post Post subject: Re: 100% JavaScript Gallery
 
Offline
Godlike Poster
Godlike Poster
Years of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membership
User avatar

Joined: Sun Oct 16, 2005 9:42 am
Posts: 8798
Karma: 17

Location: Imagine in your mind a posh country club
Steam Login Name: azcn2503
Changing things around a bit.

_________________
Follow your heart and live the dream <3


Thu Jul 14, 2011 8:13 am 
 Profile E-mail  
 
 Post Post subject: Re: 100% JavaScript Gallery
 
Offline
Godlike Poster
Godlike Poster
Years of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membership
User avatar

Joined: Sun Oct 16, 2005 9:42 am
Posts: 8798
Karma: 17

Location: Imagine in your mind a posh country club
Steam Login Name: azcn2503
Successfully reprogrammed!

Basically, the paging tab at the bottom has an ID that matches an object identifier, which contains an object with the details essential for paging - gallery number, page requested, number of pages, and the number of rows per page. It works in all browsers now.

http://www.webtagr.com/projects/gallery/gallery5.html

Let me know what you think.

Update: supports left + right + escape keystrokes on the image previewer.
Update: Highlights the image in the background, also changes page in the background (if there are pages)
Update: Actually made the above change work


Watch this video on Youtube.

Update: added an additional effect (purely CSS) that makes the image previewer slightly transparent when trying to access an image that doesn't exist (going too far to the left or too far to the right) in case the visual cue of the current near epilepsy inducing effect wasn't enough - you can now actually see that you are at the end of the gallery!

I'm pretty much going to say that this is final now. Thumbnail sizes were going to be set in the script, but I'm pretty happy with them being in CSS. You can set other things in the CSS that I haven't bothered with, like a max size for the previewer.

The AJAX mode would basically be this: Load page, load JSON separately (you will see that half of the gallery script is just a big JSON compatible object) and then send the data back to the client and process the gallery script... So the code might be something like:

Code:
galleryAdd(galleryTargetObject,galleryTitle,cells,rows,tables,pages,ajaxDataLocation)
where ajaxDataLocation might be something like 'js/gallery.js' or 'grabgallery.php' or whatever you want really...

I'll probably put up a demo later tonight. I have some real work to do now.

Update: Made a very basic gallery object creator script. It's so basic that you can only add things to the object. You can't edit or delete them. It's just to show you how easy it is to generate the gallery data. Here it is: http://www.webtagr.com/projects/gallery ... reate.html

I made this with it lol:
Code:
[{"title":"hey thar","description":"awesome gallery","contents":[{"title":"me and dad","description":"a picture of my dad getting physical with me","image":"dadtouch.jpg","thumb":"dadtouchsmall.jpg"},{"title":"dad and mum","description":"a photo my parents dont know about","image":"spycam.jpg","thumb":"spycamthumb.jpg"}]},{"title":"test gallery","description":"another test","contents":[{"title":"just this one","description":"one picture","image":"one.jpg","thumb":"one1.jpg"}]}]


Update: this code might help you make more sense of gallery:

Code:
var pageObject={};
var previewObject=null;

var galleryAjaxMode=false;

var galleryIDPrefix="gal";
var galleryPagePrefix="Page ";

var thumbWidth=100;
var thumbWidthType="%";
var thumbHeight=100;
var thumbHeightType="%";

var goverlayhover=false;
var goverlaymode=1;
var gpreloadimg=new Image();
var gpreloadpics=[];

var gCurrentPage=0;
var gCurrentRows=[];

function galleryGrab(o){
    return document.all?document.all[o]:document.getElementById?document.getElementById(o):"";
}

function galleryAdd(objString,galleryTargetObj,galleryCells,galleryRows,tablesMode,pagesMode,ajaxMode){
    !galleryCells?galleryCells=4:galleryCells;
    !galleryRows?galleryRows=3:galleryRows;
    if(tablesMode==null||tablesMode=="undefined"){ tablesMode=true; }
    if(pagesMode==null||pagesMode=="undefined"){ pagesMode=true; }
    if(ajaxMode==null||ajaxMode=="undefined"){ ajaxMode=false; }
    var o=galleryGrab(objString);
    var galleryGrid=galleryCells*galleryRows;
    var galleryCellsw=Math.floor(100/galleryCells);
    var pages=false;
    for(var i in gallery){
        if(gallery[i].hasOwnProperty("title")){
            if(gallery[i].title==galleryTargetObj){
           
                var currentGallery=gallery[i].contents;
                var galleryLen=Object.size(currentGallery);
                   
                // Image preloading
                if(document.images){ for(var j in currentGallery){ if(currentGallery[j].hasOwnProperty("image")){ gpreloadpics.push(currentGallery[j].image); } } }
               
                // Shade
                var _shade=document.createElement("div");
                    _shade.id=galleryIDPrefix+i+"_shade";
                    _shade.className="gshade gdn";
                    _shade.onclick=function(){
                        if(goverlayhover==false||goverlaymode==1){
                            galleryGrab(galleryIDPrefix+previewObject.gallery+"_cel"+previewObject.contents).className="gcell";
                            this.className="gshade gdn";
                            previewObject=null;
                        }
                    }
                    if(goverlaymode==0){
                        _shade.onmousemove=function(){
                            if(goverlayhover==false){ this.className="gshade gdt gshadehover"; }
                            else{ this.className="gshade gdt"; }
                        }
                    }
                    _shade.onselectstart=function(){ return false; };
                var _overlay=document.createElement("div");
                    _overlay.id=galleryIDPrefix+i+"_overlay";
                    _overlay.className="goverlay gdtc";
                _shade.appendChild(_overlay);
                o.appendChild(_shade);
               
                // Tabled mode
                if(tablesMode===true){
               
                    var galleryPages=Math.floor(galleryLen/galleryGrid);
                    galleryPages+=galleryLen%galleryGrid===0?0:1;
               
                    var cellOverflow=galleryCells-galleryLen%galleryCells;
                    var rowOverflow=Math.floor(galleryGrid*galleryPages%galleryLen/galleryCells);
                   
                    var _gal=document.createElement("table");
                        _gal.id=galleryIDPrefix+i+"_gal";
                        _gal.className="gcontents";
                       
                    var lastj=0;
                   
                    for(var j in currentGallery){
                        if(currentGallery[j].hasOwnProperty("image")){
                            // Add row if needed
                            if(j%galleryCells==0){
                                var _row=document.createElement("tr");
                                    _row.id=galleryIDPrefix+i+"_row"+j/galleryCells;
                                    _row.setAttribute("data-gpage",Math.floor(j/galleryGrid));
                                    if(pagesMode===true){ _row.setAttribute("data-gpages",galleryPages); }
                                if(j>=galleryGrid&&pagesMode===true){ _row.className="gdn"; }
                                else{ _row.className="gdtr"; }
                            }
                            // Add cell
                            var _cel=document.createElement("td");
                                _cel.id=galleryIDPrefix+i+"_cel"+j;
                                _cel.className="gcell";
                                _cel.onclick=function(){
                                    galleryImagePreviewer(this.id);
                                };
                                _cel.onselectstart=function(){ return false; };
                            // Add image
                            var _img=document.createElement("img");
                                _img.src=currentGallery[j].thumb;
                                _img.alt=currentGallery[j].title;
                                _img.onmousedown=function(){ return false; };
                            // Add caption
                            var _cap=document.createElement("div");
                                _cap.className="caption";
                                _cap.innerHTML=currentGallery[j].title;
                            // Append image to cell
                            _cel.appendChild(_img);
                            // Append caption to cell
                            _cel.appendChild(_cap);
                            // Append cell to row
                            _row.appendChild(_cel);
                            // Append row to gallery if needed
                            if(j>=0&&j%galleryCells==0){
                                _gal.appendChild(_row);
                            }
                            // Set paging flag if j > gallery galleryRowsid
                            if(j>=galleryGrid){ if(!pages){ pages=true; } }
                            lastj++;
                        }
                    }
                   
                    // Cell overflow
                    if(cellOverflow>0&&cellOverflow!=galleryCells){
                        for(var j=0;j<cellOverflow;j++){
                            var _cel=document.createElement("td");
                                _cel.className="gcell";
                            var _img=document.createElement("img");
                                _img.src="gallery4/hidden.png";
                            _cel.appendChild(_img);
                            _row.appendChild(_cel);
                            lastj++;
                        }
                    }
                   
                    // Row overflow (paging mode only)
                    if(pagesMode===true&&rowOverflow>0){
                        for(var j=lastj;j<lastj+(rowOverflow*galleryCells);j++){
                            if(j%galleryCells==0){
                                var _row=document.createElement("tr");
                                    _row.id=galleryIDPrefix+i+"_row"+j/galleryCells;
                                    _row.setAttribute("data-gpage",Math.floor(j/galleryGrid));
                                    if(pagesMode===true){ _row.setAttribute("data-gpages",galleryPages); }
                                if(j>=galleryGrid&&pagesMode===true){ _row.className="gdn"; }
                            }
                            var _cel=document.createElement("td");
                                _cel.className="gcell";
                            var _wrapper=document.createElement("wrapper");
                                _wrapper.className="wrapper";
                            var _img=document.createElement("img");
                                _img.src="gallery4/hidden.png";
                                _img.onmousedown=function(){ return false; }
                            _wrapper.appendChild(_img);
                            var _cap=document.createElement("div");
                                _cap.className="caption";
                                _cap.innerHTML="&nbsp;";
                            _cel.appendChild(_wrapper);
                            _cel.appendChild(_cap);
                            _row.appendChild(_cel);
                            if(j>=0&&j%galleryCells==0){
                                _gal.appendChild(_row);
                            }
                        }
                    }
                   
                    // Paging
                    if(pagesMode===true&&pages){
                        var _prow=document.createElement("tr");
                        var _cel=document.createElement("td");
                            _cel.colSpan=galleryCells;
                            _cel.className="gpages";
                        for(var j=0;j<galleryPages;j++){
                            var _anc=document.createElement("div");
                                _anc.id=galleryIDPrefix+i+"_pagetab"+j;
                                pageObject[galleryIDPrefix+i+"_pagetab"+j]={gallery:i,page:j,pages:galleryPages,rows:galleryRows};
                                _anc.innerHTML=galleryPagePrefix+(j+1);
                                if(j==0){ _anc.className="active"; }
                                else{ _anc.className="inactive"; }
                                _anc.onclick=function(){
                                    galleryPage(pageObject[this.id]);
                                };
                            _cel.appendChild(_anc);
                        }
                        _prow.appendChild(_cel);
                        _gal.appendChild(_prow);
                    }
                   
                    // Add gallery to object
                    o.appendChild(_gal);
                   
                }
               
                // Dynamic mode
                else{
                    var _gal=document.createElement("div");
                        _gal.id=galleryIDPrefix+i+"_gal";
                        _gal.className="gcontents";
                       
                    for(var j in currentGallery){
                        var _cel=document.createElement("div");
                            _cel.id=galleryIDPrefix+i+"_cel"+j;
                            _cel.className="gcell";
                            _cel.onclick=function(){
                                galleryImagePreviewer(this.id);
                            };
                            _cel.onselectstart=function(){ return false; };
                        var _img=document.createElement("img");
                            _img.src=currentGallery[j].thumb;
                            _img.alt=currentGallery[j].title;
                            _img.onmousedown=function(){ return false; };
                        var _cap=document.createElement("div");
                            _cap.className="caption";
                            _cap.innerHTML=currentGallery[j].title;
                        _cel.appendChild(_img);
                        _cel.appendChild(_cap);
                        _gal.appendChild(_cel);
                    }
                       
                    o.appendChild(_gal);
                }
               
            }
        }
    }
    galleryImagePreloader();
}

// Pager
function galleryPage(args){
    // change page tab classNames
    for(var i=0;i<args.pages;i++){
        galleryGrab(galleryIDPrefix+args.gallery+"_pagetab"+i).className=i==args.page?"active":"inactive";
    }
    // change row classNames
    args.pages=parseInt(args.pages);
    args.rows=parseInt(args.rows);
    for(var i=0;i<args.pages*args.rows;i+=args.rows){
        for(var j=0;j<args.rows;j++){
            var rowNum=i+j;
            if(galleryGrab(galleryIDPrefix+args.gallery+"_row"+rowNum)){
                galleryGrab(galleryIDPrefix+args.gallery+"_row"+rowNum).className=args.page==(i/args.rows)?"gdtr":"gdn";
            }
        }
    }
}

// Preloader
function galleryImagePreloader(){
    for(var i in gpreloadpics){ gpreloadimg.src=gpreloadpics[i]; }
}

// Previewer
function galleryImagePreviewer(objString){
    galleryGrab(objString).className="gcell active";
    var galleryNum=objString.split("_")[0].split("gal")[1];
    var contentsNum=objString.split("_")[1].split("cel")[1];
    var currentGallery=gallery[galleryNum].contents[contentsNum];
    previewObject={gallery:galleryNum,contents:contentsNum};
    var _shade=galleryGrab(galleryIDPrefix+galleryNum+"_shade");
    _shade.className="gshade gdt";
    var _overlay=galleryGrab(galleryIDPrefix+galleryNum+"_overlay");
    var _cel=document.createElement("div");
        _cel.className="gcell";
        _cel.onmouseover=function(){ goverlayhover=true; };
        _cel.onmouseout=function(){ goverlayhover=false; };
    var _img=document.createElement("img");
        _img.src=currentGallery.image;
        _img.alt=currentGallery.title;
        _img.onmousedown=function(){ return false; };
    var _cap=document.createElement("div");
        _cap.className="caption";
        _cap.innerHTML=currentGallery.title;
    var _sub=document.createElement("div");
        _sub.className="subcaption";
        _sub.innerHTML=currentGallery.description;
    _cel.appendChild(_img);
    _cel.appendChild(_cap);
    _cel.appendChild(_sub);
    _overlay.innerHTML="";
    _overlay.appendChild(_cel);
   
    window.onkeydown=function(e){
        if(previewObject!=null){
            switch(e.keyCode){
                case 37: // left
                    if(!gallery[previewObject.gallery].contents[parseInt(previewObject.contents-1)]){
                        galleryGrab(galleryIDPrefix+previewObject.gallery+"_shade").className="gshade gdt gshadealert";
                    }
                break;
                case 39: // right
                    if(!gallery[previewObject.gallery].contents[parseInt(previewObject.contents-1+2)]){
                        galleryGrab(galleryIDPrefix+previewObject.gallery+"_shade").className="gshade gdt gshadealert";
                    }
                break;
            }
        }
    }
   
    window.onkeyup=function(e){
        if(previewObject!=null){
            switch(e.keyCode){
                case 27: // esc
                    galleryGrab(galleryIDPrefix+previewObject.gallery+"_cel"+previewObject.contents).className="gcell";
                    galleryGrab(galleryIDPrefix+previewObject.gallery+"_shade").className="gshade gdn";
                    previewObject=null;
                break;
                case 37: // left
                    if(gallery[previewObject.gallery].contents[parseInt(previewObject.contents-1)]){
                        var galleryPagesParent=galleryGrab(galleryIDPrefix+previewObject.gallery+"_cel"+parseInt(previewObject.contents-1)).parentNode;
                        if(galleryPagesParent.getAttribute("data-gpages")>1){
                            galleryPage(pageObject[galleryIDPrefix+previewObject.gallery+"_pagetab"+galleryPagesParent.getAttribute("data-gpage")]);
                        }
                        galleryGrab(galleryIDPrefix+previewObject.gallery+"_cel"+previewObject.contents).className="gcell";
                        galleryImagePreviewer(galleryIDPrefix+previewObject.gallery+"_cel"+parseInt(previewObject.contents-1));
                    }
                    else{
                        galleryGrab(galleryIDPrefix+previewObject.gallery+"_shade").className="gshade gdt";
                    }
                break;
                case 39: // right
                    if(gallery[previewObject.gallery].contents[parseInt(previewObject.contents-1+2)]){
                        var galleryPagesParent=galleryGrab(galleryIDPrefix+previewObject.gallery+"_cel"+parseInt(previewObject.contents-1+2)).parentNode;
                        if(galleryPagesParent.getAttribute("data-gpages")>1){
                            galleryPage(pageObject[galleryIDPrefix+previewObject.gallery+"_pagetab"+galleryPagesParent.getAttribute("data-gpage")]);
                        }
                        galleryGrab(galleryIDPrefix+previewObject.gallery+"_cel"+previewObject.contents).className="gcell";
                        galleryImagePreviewer(galleryIDPrefix+previewObject.gallery+"_cel"+parseInt(previewObject.contents-1+2));
                    }
                    else{
                        galleryGrab(galleryIDPrefix+previewObject.gallery+"_shade").className="gshade gdt";
                    }
                break;
            }
        }
    }
}

Object.size=function(o){
    var size=0,k;
    for(k in o){
        if(o.hasOwnProperty(k)){ size++; }
    }
    return size;
};

_________________
Follow your heart and live the dream <3


Thu Jul 14, 2011 1:01 pm 
 Profile E-mail  
 
 Post Post subject: Re: 100% JavaScript Gallery
 
Offline
Malevolent Artificial Intelligence
Malevolent Artificial Intelligence
Years of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membershipYears of membership
User avatar

Joined: Wed Sep 14, 2005 3:37 pm
Posts: 6434
Karma: 4
You should try and find a way of making money off of this. ;)

_________________
In which the unthinkable happened.
Image
Signature created by schlürbi. :D


Wed Jul 20, 2011 9:20 am 
 Profile E-mail  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 29 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Karma functions powered by Karma MOD © 2007, 2009 m157y