2008-08-26 15:10:33 +02:00
|
|
|
/*
|
|
|
|
* Image scrolling JQuery code.
|
|
|
|
*
|
2009-07-11 21:14:29 +02:00
|
|
|
* Copyright (c) 2007, 2008, 2009 Jan Dittberner <jan@dittberner.info>
|
2008-08-26 15:10:33 +02:00
|
|
|
* Jan Dittberner IT-Consulting & -Solutions
|
|
|
|
* Cottbuser Str. 1, D-01129 Dresden
|
2008-08-26 21:04:50 +02:00
|
|
|
*
|
|
|
|
* This file is part of the ScrollingJQueryGallery component of the
|
|
|
|
* gnuviech-server.de Websitetools
|
|
|
|
*
|
|
|
|
* ScrollingJQueryGallery is free software: you can redistribute it
|
|
|
|
* and/or modify it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* ScrollingJQueryGallery is distributed in the hope that it will be
|
|
|
|
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with ScrollingJQueryGallery. If not, see
|
|
|
|
* <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* Version: $Id$
|
2008-08-26 15:10:33 +02:00
|
|
|
*/
|
2008-08-28 00:04:20 +02:00
|
|
|
var imgprefix = "bilder";
|
2008-08-26 15:10:33 +02:00
|
|
|
|
|
|
|
function getPathParts(imagesrc) {
|
|
|
|
var filename = imagesrc.substring(imagesrc.lastIndexOf("/") + 1);
|
2008-08-28 00:04:20 +02:00
|
|
|
var pathstart = imagesrc.substring(0, imagesrc.lastIndexOf("/"));
|
|
|
|
// run through directories until imgprefix is found
|
|
|
|
var dirstack = new Array();
|
|
|
|
var current = pathstart.substring(pathstart.lastIndexOf("/") + 1);
|
|
|
|
while (current != imgprefix) {
|
|
|
|
dirstack.push(current);
|
|
|
|
pathstart = pathstart.substring(0, pathstart.lastIndexOf("/"));
|
|
|
|
current = pathstart.substring(pathstart.lastIndexOf("/") + 1);
|
2008-08-26 15:10:33 +02:00
|
|
|
}
|
2008-08-28 00:04:20 +02:00
|
|
|
var galleryname = dirstack.pop();
|
|
|
|
var dirname = null;
|
|
|
|
if (dirstack.length > 0) {
|
|
|
|
dirname = dirstack.pop();
|
|
|
|
}
|
|
|
|
return {
|
2008-08-26 15:10:33 +02:00
|
|
|
'filename' : filename,
|
|
|
|
'dirname' : dirname,
|
2008-08-28 00:04:20 +02:00
|
|
|
'gallery' : galleryname,
|
|
|
|
'pathstart' : pathstart
|
2008-08-26 15:10:33 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
function updateContentImage(pathParts) {
|
2008-08-28 00:04:20 +02:00
|
|
|
$.getJSON("ajaxrequest.php", {
|
|
|
|
"imagename" : pathParts.filename,
|
|
|
|
"galleryname" : pathParts.gallery
|
|
|
|
}, function(data, textStatus) {
|
2008-08-28 22:06:19 +02:00
|
|
|
$("#imagedescription").text(data["label"]);
|
|
|
|
$("#content_main img").attr("alt", data["label"]);
|
2008-08-28 00:04:20 +02:00
|
|
|
$("#content_main img").attr("src", data["preview"]);
|
|
|
|
$("#content_main a").attr("href", data["full"]);
|
2008-08-28 22:06:19 +02:00
|
|
|
$("#content_main a").attr("title", data["label"]);
|
2008-08-28 20:17:57 +02:00
|
|
|
document.title = data["title"];
|
2008-08-28 00:04:20 +02:00
|
|
|
});
|
2008-08-26 15:10:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$(document).ready(function() {
|
2009-07-11 21:14:29 +02:00
|
|
|
if (themetype == 'horizontal') {
|
|
|
|
$("#arrleft").mouseover(function() {
|
|
|
|
$("#scrollable").animate({
|
|
|
|
left: "0px"
|
|
|
|
}, 500);
|
|
|
|
}).mouseout(function() {
|
|
|
|
$("#scrollable").stop();
|
|
|
|
});
|
|
|
|
$("#arrright").mouseover(function() {
|
2009-07-11 21:14:36 +02:00
|
|
|
var offset = parseInt($("#imgscroller").css("width")) -
|
2009-07-11 21:14:29 +02:00
|
|
|
parseInt($("#scrollable").css("width"));
|
|
|
|
$("#scrollable").animate({
|
|
|
|
left: offset + "px"
|
|
|
|
}, 500);
|
|
|
|
}).mouseout(function() {
|
|
|
|
$("#scrollable").stop();
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
$('#arrup').mouseover(function() {
|
|
|
|
$('#scrollable').animate({
|
|
|
|
top: "0px"
|
|
|
|
}, 500);
|
|
|
|
}).mouseout(function() {
|
|
|
|
$('#scrollable').stop();
|
|
|
|
});
|
|
|
|
$('#arrdown').mouseover(function() {
|
2009-07-11 21:14:36 +02:00
|
|
|
var offset = parseInt($('#imgscroller').css('height')) -
|
2009-07-11 21:14:29 +02:00
|
|
|
parseInt($('#scrollable').css('height'));
|
|
|
|
$('#scrollable').animate({
|
|
|
|
top: offset + "px"
|
|
|
|
}, 500);
|
|
|
|
}).mouseout(function() {
|
|
|
|
$('#scrollable').stop();
|
|
|
|
});
|
|
|
|
}
|
2008-08-26 15:10:33 +02:00
|
|
|
$("#backbtn").click(function() {
|
2008-08-28 00:04:20 +02:00
|
|
|
$("div.thumbnail img").each(function(i) {
|
|
|
|
var curparts = getPathParts($("img#contentimg").attr("src"));
|
|
|
|
var myparts = getPathParts($(this).attr("src"));
|
|
|
|
if ((curparts.gallery == myparts.gallery) &&
|
|
|
|
(curparts.filename == myparts.filename)) {
|
|
|
|
var matched = $("div.thumbnail img");
|
|
|
|
var prevparts;
|
|
|
|
if (i > 0) {
|
|
|
|
prevparts = getPathParts(
|
|
|
|
$(matched.get(i-1)).attr("src"));
|
|
|
|
} else {
|
|
|
|
prevparts = getPathParts(
|
|
|
|
$(matched.get(matched.length-1)).attr("src"));
|
2008-08-26 15:10:33 +02:00
|
|
|
}
|
2008-08-28 00:04:20 +02:00
|
|
|
updateContentImage(prevparts);
|
|
|
|
return false;
|
2008-08-26 15:10:33 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
$("#fwdbtn").click(function() {
|
2008-08-28 00:04:20 +02:00
|
|
|
$("div.thumbnail img").each(function(i) {
|
|
|
|
var curparts = getPathParts($("img#contentimg").attr("src"));
|
|
|
|
var myparts = getPathParts($(this).attr("src"));
|
|
|
|
if ((curparts.gallery == myparts.gallery) &&
|
|
|
|
(curparts.filename == myparts.filename)) {
|
|
|
|
var matched = $("div.thumbnail img");
|
|
|
|
var nextparts;
|
|
|
|
if (i < matched.length-1) {
|
|
|
|
nextparts = getPathParts(
|
|
|
|
$(matched.get(i+1)).attr("src"));
|
|
|
|
} else {
|
|
|
|
nextparts = getPathParts(
|
|
|
|
$(matched.get(0)).attr("src"));
|
|
|
|
}
|
|
|
|
updateContentImage(nextparts);
|
|
|
|
return false;
|
2008-08-26 15:10:33 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
$("div.thumbnail img").mouseover(function() {
|
|
|
|
updateContentImage(getPathParts(this.src));
|
|
|
|
});
|
|
|
|
});
|