removed a little duplication

This commit is contained in:
Knut Forkalsrud 2011-03-28 00:23:29 -07:00
parent 1e04937fab
commit 12b91ab1ec

View file

@ -97,15 +97,19 @@ $(function() {
$.getJSON('album/photos.json', function(data, textStatus) {
$("#name").html(data.name);
var thmb = 250;
var picSize = 800;
var movieSize = 640;
$.each(data.contents, function(idx, entry) {
var dim = scale(entry.width, entry.height, 250);
var dim = scale(entry.width, entry.height, thmb);
var gridDiv = $("<div class=\"grid\">\n"
+ " <span class=\"name\">" + entry.name + "</span><br/>\n"
+ " <div class=\"imgborder\"><a class=\"ss\" id=\"ent" + idx + "\" href=\"album" + entry.path + "?size=800\" title=\"" + entry.name + "\">"
+ "<img class=\"picture\" src=\"album" + (entry.type == "movie" ? entry.path + ".frame" : entry.path) + "?size=250\" border=\"0\" width=\"" + dim.w + "\" height=\"" + dim.h + "\"/></a></div>\n"
+ " <div class=\"imgborder\"><a class=\"ss\" id=\"ent" + idx + "\" href=\"album" + entry.path + "?size=" + picSize + "\" title=\"" + entry.name + "\">"
+ "<img class=\"picture\" src=\"album" + (entry.type == "movie" ? entry.path + ".frame" : entry.path) + "?size=" + thmb + "\" border=\"0\" width=\"" + dim.w + "\" height=\"" + dim.h + "\"/></a></div>\n"
+ "<p id=\"" + entry.name + "\" class=\"caption\"></p>\n"
+ "</div>\n");
gridDiv.appendTo('body');
@ -116,7 +120,9 @@ $(function() {
switch (entry.type) {
case "movie":
$("#ent" + idx).attr("rel", "album").attr("href", "/album" + entry.path + ".movie?size=640").fancybox({
var size = scale(entry.width, entry.height, movieSize);
var href = "album" + escape(entry.path) + ".movie?size=" + movieSize;
$("#ent" + idx).attr("rel", "album").attr("href", href).fancybox({
'titlePosition' : 'inside',
'transitionIn' : 'elastic',
'transitionOut' : 'elastic',
@ -125,28 +131,34 @@ $(function() {
'titleFormat' : formatTitle,
'padding' : 0,
'href' : "assets/flowplayer/flowplayer-3.0.3.swf",
'width' : entry.width,
'height' : entry.height,
'width' : size.w,
'height' : size.h,
'type' : 'swf',
'swf' : {
'allowfullscreen' : 'true',
'wmode' : 'transparent',
'flashvars':
"config={ 'clip': { 'url': '/album" + escape(entry.path) + ".movie?size=640' },\
'controls': {\
'url': 'assets/flowplayer/flowplayer.controls-3.0.3.swf',\
'backgroundColor': 'transparent', 'progressColor': 'transparent', 'bufferColor': 'transparent',\
'play':true,\
'fullscreen':true,\
'autoHide': 'always'\
}\
"config={\
'clip': {\
'url': '" + href + "'\
},\
'plugins': {\
'controls': {\
'url': 'assets/flowplayer/flowplayer.controls-3.0.3.swf',\
'backgroundColor': 'transparent',\
'progressColor': 'transparent',\
'bufferColor': 'transparent',\
'play':true,\
'fullscreen':true,\
'autoHide': 'always'\
}\
}\
}"
}
}
});
break;
case "image":
var largeDim = scale(entry.width, entry.height, 800);
var largeDim = scale(entry.width, entry.height, picSize);
$("#ent" + idx).attr("rel", "album").fancybox({
'titlePosition' : 'inside',
'transitionIn' : 'elastic',