Well, GreyBox will work. There are a few ways one can go with it. What I did was use this code in the head:
Code:
<!DOCTYPE html>
<html lang="en">
<head>
<title>CSS Image Gallery Enhanced w/jQuery and GreyBox</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<link rel="stylesheet" title="hovercss" href="index_files/gallerynoscript.css" type="text/css">
<link rel="alternate stylesheet" title="focuscss" href="index_files/gallery.css" type="text/css">
<link href="greybox/gb_styles.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
var GB_ROOT_DIR = "greybox/";
</script>
<script type="text/javascript" src="greybox/AJS.js"></script>
<script type="text/javascript" src="greybox/AJS_fx.js"></script>
<script type="text/javascript" src="greybox/gb_scripts.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
<script type="text/javascript">
(function($){
var iever = /MSIE (\d+)/.exec(navigator.userAgent), linkset = [], imageset = [],
imgre = /\.(jpg|jpeg|gif|bmp|png)($|#|\?)/i, ie7 = true;
if(!iever || iever[1] > 7){
$('link[title="focuscss"]').get(0).disabled = true;
$('link[title="hovercss"]').get(0).disabled = true;
$('link[title="focuscss"]').get(0).disabled = false;
ie7 = false;
}
$(function(){
var activetrigger = document.getElementById('first');
function loadactive(){activetrigger.focus();}
!ie7 && loadactive();
$('.thumbnail').bind('focus click', function(e){
if(e.type === 'click'){
this.focus();
if(ie7 || this.href !== 'javascript:void(0);' && e.target.nodeName === 'SPAN'){
if(imgre.test(this.href)){
GB_showImageSet(imageset, this.getAttribute('data-index'));
} else if(this.getAttribute('data-index')) {
GB_showFullScreenSet(linkset, this.getAttribute('data-index'));
}
}
}
activetrigger = this;
e.preventDefault();
}).not('[href="javascript:void(0);"]').find('span').css({cursor: 'pointer'}).end().each(function(){
if(imgre.test(this.href)){
imageset.push({caption: this.getAttribute('data-title') || this.title || '', url: this.href});
this.setAttribute('data-index', imageset.length);
} else {
linkset.push({caption: this.getAttribute('data-title') || this.title || '', url: this.href});
this.setAttribute('data-index', linkset.length);
}
});
!ie7 && $(document).mousedown(function(){setTimeout(loadactive, 0);});
});
})(jQuery);
</script>
</head>
The two stylesheets with highlights in their link tags are exactly the same except that the one with the title 'hovercss' has the :focus pseudo selectors for the thumbnail gallery changed to :hover pseudo selectors (see * below for more explanation). If javascript is disabled or IE 7 or less is used, these (hovercss) rules will be used. Otherwise the script swaps them and the 'focuscss' rules are used. This gives maximum utility under various circumstances.
I chose to allow either or both of image sets or link sets but kept them separate. If you have only one or the other, only those will be used. The script can tell which by the href attribute of the link. So if you have a link like so (do not use the rel attribute for any of these):
Code:
<a class="thumbnail" href="index_files/238_002.jpg">
It will go into the image set. Any href (case insensitive) ending in .jpg, .jpeg, .gif, .bmp and .png will go into the image set. If you have a link like this:
Code:
<a class="thumbnail" href="somepage.htm">
with any other extension, or no extension, like to a folder or a domain, it will go into the link set.
A link like this will be ignored by GreyBox but still act normally as a thumbnail gallery trigger:
Code:
<a class="thumbnail" href="javascript:void(0);">
It must use that exact syntax for its href though.
Once you've setup your thumbnails how you want them. The GreyBox ones will activate their greybox only on the text in the larger image span section of that thumnail, except in IE 7 and less, which cannot handle the focus gallery. There it will activate on click of the thumbnail, and the thumbnail gallery will work as a hover gallery. For non-javascript enabled browsers, they too will get a hover gallery and can click on the links to load the page or image directly into the browser.
You can add things to the thumbnail links.
You can give some or all of them a target attribute. That will only be used by non-javascript browsers and can be used to have them open a new tab or window, and/or to target an iframe in a noscript tag for what will be GreyBox links for all other browsers.
You can give some or all of them a data-title attribute:
Code:
<a class="thumbnail" href="http://www.javascriptkit.com/" data-title="Javascript Kit">
That will be used as the title/caption in the greybox. Or you can use just a title attribute for the same thing. But a title attribute shows on hover of all parts of the thumbnail including its contained span and larger image, so it's unsightly in many cases. You can do both and the data-title will override title in the greybox, but the actual title will show up when hovering the thumbnail and it's contained span and larger image. If you use neither, there will be no title/caption in the greybox and there will be no 'tooltip' on hover.
The ideal situation might be to use data-title on the thumbnail link and set a title attribute for the thumbnail image img tag. That will show the data-title only in the greybix and the img title only on hover of the thumbnail image:
Code:
<a class="thumbnail" href="http://www.javascriptkit.com/" data-title="Javascript Kit DOT Com"><img src="some_thumb.jpg" alt="" title="Some Title"> . . .
That's pretty much it. Any questions just ask.
*Your stylesheet is /cheryl/cheryl.css so you would change it in three places:
Code:
.thumbnail:focus{
background-color: transparent;
}
.thumbnail:focus img{
border: 1px solid #000;
}
.thumbnail span{ /*CSS for enlarged image*/
position: absolute;
left: -1000px;;
visibility: hidden;
color: black;
text-decoration: none;
}
.thumbnail span img{ /*CSS for enlarged image*/
border-width: 0;
padding: 0;
}
.thumbnail:focus span{ /*CSS for enlarged image*/
visibility: visible;
top: 115px;
left: 110px; /*position where enlarged image should offset horizontally */
z-index: 50;
}
making those :hover and save that as - say /cheryl/cherylnoscript.css, then your stylesheet links in the head would be:
Code:
<link rel="stylesheet" title="hovercss" href="/cheryl/cherylnoscript.css" type="text/css">
<link rel="alternate stylesheet" title="focuscss" href="/cheryl/cheryl.css" type="text/css">
Bookmarks