/**
* Animation javascript file
* @author Johan Attali
*/
/**
* Sets an element property for future animation
* @param elem Element to setup
* @param type can be width or height... type to setup
* @param cur current size
* @param ma max size
* @param mi min size
*/
function setElementProperty(elem, type, cur, ma, mi)
{
if (!mi) mi = 0;
if (type == 'width')
{
elem.currentWidth = cur;
elem.maxWidth = ma;
elem.minWidth = mi;
}
else if (type == 'height')
{
elem.currentHeight = cur;
elem.maxHeight = ma;
elem.minHeight = mi;
}
else if (type == 'opacity')
{
elem.currentOpacity = cur;
elem.maxOpacity = ma;
elem.minOpacity = mi;
}
}
function doWidthChangeMem(elem,startWidth,endWidth,steps,intervals,powr)
{
//Width changer with Memory by www.hesido.com
if (elem.widthChangeMemInt)
window.clearInterval(elem.widthChangeMemInt);
var actStep = 0;
elem.widthChangeMemInt = window.setInterval(
function() {
elem.currentWidth = easeInOut(startWidth,endWidth,steps,actStep,powr);
elem.style.width = elem.currentWidth + "px";
actStep++;
if (actStep > steps) window.clearInterval(elem.widthChangeMemInt);
}
,intervals)
}
function doOpacityChangeMem(elem,startOp,endOp,steps,intervals,powr)
{
//Width changer with Memory by www.hesido.com
if (elem.opacityChangeMemInt)
window.clearInterval(elem.opacityChangeMemInt);
var actStep = 0;
elem.opacityChangeMemInt = window.setInterval(
function() {
elem.currentOpacity = easeInOut(startOp,endOp,steps,actStep,powr);
elem.style.opacity = elem.currentOpacity/100.0;
elem.style.filter = "alpha(opacity="+elem.currentOpacity+")";
actStep++;
if (actStep > steps) window.clearInterval(elem.opacityChangeMemInt);
}
,intervals)
}
function doHeightChangeMem(elem,startWidth,endWidth,steps,intervals,powr)
{
//Width changer with Memory by www.hesido.com
if (elem.heightChangeMemInt)
window.clearInterval(elem.heightChangeMemInt);
var actStep = 0;
elem.heightChangeMemInt = window.setInterval(
function()
{
elem.currentHeight = easeInOut(startWidth,endWidth,steps,actStep,powr);
elem.style.height = elem.currentHeight+ "px";
actStep++;
if (actStep > steps) window.clearInterval(elem.heightChangeMemInt);
}
,intervals)
}
function close_element(elem, dir, steps, intervals, powr)
{
if (!powr) powr = 0.5;
if (!intervals) intervals = 20;
if (!steps) steps = 20;
if (dir == "up")
doHeightChangeMem(elem,elem.currentHeight,elem.minHeight, steps, intervals,powr);
else if (dir == 'left')
doWidthChangeMem(elem,elem.currentWidth, elem.minWidth, steps, intervals,powr);
else if (dir == 'fade')
doOpacityChangeMem(elem,elem.currentOpacity, elem.minOpacity, steps, intervals,powr);
if ($('n_slideshow') == null || $('n_slideshow').style.opacity == 0)
new Fx.Opacity('footer', {duration: 400 }).custom(0,1);
}
function show_element(elem, dir, steps, intervals, powr)
{
if (!powr) powr = 0.5;
if (!intervals) intervals = 20;
if (!steps) steps = 20;
if (dir == "down")
doHeightChangeMem(elem,elem.currentHeight, elem.maxHeight, steps, intervals,powr);
else if (dir == 'right')
doWidthChangeMem(elem,elem.currentWidth, elem.maxWidth, steps, intervals,powr);
else if (dir = 'fade')
doOpacityChangeMem(elem,elem.currentOpacity, elem.maxOpacity, steps, intervals, powr);
new Fx.Opacity('footer', {duration: 400 }).custom(1,0);
}
function adjust_element(elem, dir, steps, intervals, powr)
{
if (!powr) powr = 0.5;
if (!intervals) intervals = 20;
if (!steps) steps = 20;
if (dir == "down")
doHeightChangeMem(elem,elem.currentHeight, elem.maxHeight, steps, intervals, powr);
else if (dir == "up")
doHeightChangeMem(elem,elem.currentHeight,elem.minHeight, steps, intervals, powr);
else if (dir == 'left')
doWidthChangeMem(elem,elem.currentWidth, elem.minWidth, steps, intervals, powr);
else if (dir == 'right')
doWidthChangeMem(elem,elem.currentWidth, elem.maxWidth, steps, intervals, powr);
else if (dir == 'show')
doOpacityChangeMem(elem,elem.currentOpacity, elem.maxOpacity, steps, intervals, powr);
else if (dir == 'fade')
doOpacityChangeMem(elem,elem.currentOpacity, elem.minOpacity, steps, intervals, powr);
}
function easeInOut(minValue,maxValue,totalSteps,actualStep,powr)
{
//Generic Animation Step Value Generator By www.hesido.com
var delta = maxValue - minValue;
var stepp = minValue+(Math.pow(((1 / totalSteps) * actualStep), powr) * delta);
return Math.ceil(stepp)
}
function show_hide_panel()
{
var controls = document.getElementById('panel-controls');
var panel = document.getElementById('panel');
var content = document.getElementById('panel-content');
if (controls.innerHTML.search(/lt;/) != -1)
{
controls.innerHTML = '>';
new Fx.Width('panel', {duration: 450}).custom(83, 10);
new Fx.Height('panel-content', {duration: 450}).custom(73, 0);
new Fx.Height('panel', {duration: 450}).custom(73, 14);
// close_element(panel, 'left', 15, 15, 0.7);
// close_element(content, 'up', 15, 15, 0.7);
}
else
{
controls.innerHTML = '<';
new Fx.Width('panel', {duration: 450}).custom(10, 83);
new Fx.Height('panel-content', {duration: 450}).custom(0, 75);
new Fx.Height('panel', {duration: 450}).custom(14, 89);
//show_element(panel, 'right', 15, 15, 0.6);
//show_element(content, 'down', 15, 15, 0.6);
}
/*if (elem.currentWidth > 0 )
close_element(elem, 'left');
else
doWidthChangeMem(elem,elem.currentWidth,elem.currentWidth,15);*/
}
function hide_panel()
{
new Fx.Width('panel', {duration: 450}).toggle();
var maxPictures = document.body.getAttribute("orient") == 'profile' ? 16 : 12;
lock();
setTimeout(function () { new Fx.Width('panel-showpanel', {duration: 400}).custom(0, 20); }, 450);
setTimeout(function () { new Fx.Opacity('panel-showpanel', {duration: 400}).custom(0, 0.7); }, 500);
setTimeout(function()
{
// When the orientation is changed we don't want the pictures behind to overlap
// with the image being seen
new Ajax.Updater('content', '/services/iphone/update',
{
parameters: 'opacity=1'+
'&maxPictures='+maxPictures,
onSuccess: updatePicturesLayout,
onComplete: unlock
});
},
900);
/*setTimeout(function()
{
// Updates the number of pictures that can be seen within the window
// We can actually see a little more on profile mode
new Ajax.Request('tools/setSessionAttribute.jsp',
{
method:'get',
parameters: 'attribute=maxPictures&value='+maxPictures,
onSuccess: updatePicturesLayout
});
},
900);*/
}
function show_panel()
{
new Fx.Opacity('panel-showpanel', {duration: 400}).custom(0.7, 0);
new Fx.Width('panel-showpanel', {duration: 400}).custom(20, 0);
lock();
setTimeout("new Fx.Width('panel', {duration: 450}).custom(0, 158);", 400);
var maxPictures = document.body.getAttribute("orient") == 'profile' ? 14 : 10;
setTimeout(function()
{
// When the orientation is changed we don't want the pictures behind to overlap
// with the image being seen
new Ajax.Updater('content', '/services/iphone/update',
{
parameters: 'opacity=1'+
'&maxPictures='+maxPictures,
onSuccess: updatePicturesLayout,
onComplete: unlock
});
},
900);
}