in assets/www/scripts/MetroJs.lt.js [546:749]
$this.flip = function (callback) {
if (typeof (callback) == "undefined" || callback == null)
callback = null;
if (tdata.repeatCount > -1) {
if (tdata.loopCount > tdata.repeatCount) {
tdata.stopTimer(false);
tdata.loopCount = 0;
// TODO: debug and remove instances of jQuery.browser for compatibility with jq 1.8+
if (jQuery.browser.msie) /* straighten out issue with loopcount in IE */
tdata.loopCount += 1;
tdata.hasRun = false;
$this.data("LiveTile", tdata);
return;
} else {
tdata.loopCount += 1;
}
}
if (canFlip3d && tdata.useHwAccel) {
var spd = (tdata.speed * 2); // accelerated flip speeds are calculated on 1/2 rotation rather than 1/4 rotation like jQuery animate
var duration = spd + 'ms';
var aniFName = (tdata.direction == "vertical") ? 'flipfront180' : 'flipfrontY180';
var aniBName = (tdata.direction == "vertical") ? 'flipback180' : 'flipbackY180';
var data = $firstContainer.data("tile");
if (typeof (data.animated) != "undefined" && data.animated == true) {
return;
}
data.animated = true;
if (doAnimations) {
if (tdata.isReversed) {
var uCss = {
WebkitAnimationPlayState: 'running', WebkitAnimationName: aniBName, WebkitAnimationDuration: duration,
MozAnimationPlayState: 'running', MozAnimationName: aniBName, MozAnimationDuration: duration,
OAnimationPlayState: 'running', OAnimationName: aniBName, OAnimationDuration: duration,
msAnimationPlayState: 'running', msAnimationName: aniBName, msAnimationDuration: duration,
AnimationPlayState: 'running', AnimationName: aniBName, AnimationDuration: duration
};
$firstContainer.css(uCss).data("tile", data);
uCss.WebkitAnimationName = aniFName;
uCss.MozAnimationName = aniFName;
uCss.msAnimationName = aniFName;
uCss.OAnimationName = aniFName;
uCss.AnimationName = aniFName;
$scndContainer.css(uCss).data("tile", data);
window.setTimeout(function () {
if (swapBackSource) { // change the source image when the animation is finished
var isRandom = stgs.backIsRandom;
var index = staticIndexBack;
if (isRandom) {
//make sure the random bag is ready
if (backRandomBag.length == 0) {
for (var i = 0; i < stgs.backImages.length; i++) {
//make sure there's not an immediate repeat
if (i != prevBackIndex || stgs.backImages.length == 1)
backRandomBag[i] = i;
}
backRandomBag = privMethods.shuffleArray(backRandomBag);
}
index = backRandomBag.pop();
prevBackIndex = index;
}
privMethods.handleSwap($scndContainer, false, stgs, index);
staticIndexBack += 1;
if (staticIndexBack >= stgs.backImages.length) {
staticIndexBack = 0;
}
}
stgs.animationComplete(tdata, $firstContainer, $scndContainer);
if (callback != null)
callback();
data.animated = false;
$firstContainer.data("tile", data);
$scndContainer.data("tile", data);
}, spd);
} else {
var dCss = { WebkitAnimationPlayState: 'running', WebkitAnimationName: aniFName, WebkitAnimationDuration: duration,
MozAnimationPlayState: 'running', MozAnimationName: aniFName, MozAnimationDuration: duration,
OAnimationPlayState: 'running', OAnimationName: aniFName, OAnimationDuration: duration,
msAnimationPlayState: 'running', msAnimationName: aniFName, msAnimationDuration: duration,
AnimationPlayState: 'running', AnimationName: aniFName, AnimationDuration: duration
};
$firstContainer.css(dCss).data("tile", data);
dCss.WebkitAnimationName = aniBName;
dCss.MozAnimationName = aniBName;
dCss.msAnimationName = aniBName;
dCss.OAnimationName = aniBName;
dCss.AnimationName = aniBName;
$scndContainer.css(dCss).data("tile", data);
window.setTimeout(function () {
if (swapFrontSource) {
// change the source image when the animation is finished
var isRandom = stgs.frontIsRandom;
var index = staticIndexFront;
if (isRandom) {
//make sure the random bag is ready
if (frontRandomBag.length == 0) {
for (var i = 0; i < stgs.frontImages.length; i++) {
//make sure there's not an immediate repeat
if (i != prevBackIndex || stgs.frontImages.length == 1)
frontRandomBag[i] = i;
}
frontRandomBag = privMethods.shuffleArray(frontRandomBag);
}
index = frontRandomBag.pop();
prevFrontIndex = index;
}
privMethods.handleSwap($firstContainer, true, stgs, index);
staticIndexFront += 1;
if (staticIndexFront >= stgs.frontImages.length) {
staticIndexFront = 0;
}
}
stgs.animationComplete(tdata, $scndContainer, $firstContainer);
if (callback != null) {
callback();
}
data.animated = false;
$firstContainer.data("tile", data);
$scndContainer.data("tile", data);
}, spd);
}
}
//an interval isnt needed
tdata.isReversed = !tdata.isReversed;
} else {
//crossbrowser single tile flip illusion (works best with images)
if (tdata.isReversed) {
var upCss = (tdata.direction == "vertical") ?
{ height: '0px', width: '100%', marginTop: margin + 'px', opacity: '0'} :
{ height: '100%', width: '0px', marginLeft: margin + 'px', opacity: '0' };
var upCss2 = (tdata.direction == "vertical") ?
{ height: '100%', width: '100%', marginTop: '0px', opacity: '1'} :
{ height: '100%', width: '100%', marginLeft: '0px', opacity: '1' };
$firstContainer.stop().animate(upCss, { duration: tdata.speed });
window.setTimeout(function () {
$scndContainer.stop().animate(upCss2, { duration: tdata.speed });
if (swapFrontSource) {
var isRandom = stgs.frontIsRandom;
var index = staticIndexFront;
if (isRandom) {
//make sure the random bag is ready
if (frontRandomBag.length == 0) {
for (var i = 0; i < stgs.frontImages.length; i++) {
//make sure there's not an immediate repeat
if (i != prevFrontIndex || stgs.frontImages.length == 1)
frontRandomBag[i] = i;
}
frontRandomBag = privMethods.shuffleArray(frontRandomBag);
}
index = frontRandomBag.pop();
prevFrontIndex = index;
}
privMethods.handleSwap($firstContainer, true, stgs, index);
staticIndexFront += 1;
if (staticIndexFront >= stgs.frontImages.length) {
staticIndexFront = 0;
}
}
tdata.isReversed = !tdata.isReversed;
stgs.animationComplete(tdata, $scndContainer, $firstContainer);
if (callback != null)
callback();
}, tdata.speed);
} else {
var dwnCss = (tdata.direction == "vertical") ?
{ height: '0px', width: '100%', marginTop: margin + 'px', opacity: '0'} :
{ height: '100%', width: '0px', marginLeft: margin + 'px', opacity: '0' };
var dwnCss2 = (tdata.direction == "vertical") ?
{ height: '100%', width: '100%', marginTop: '0px', opacity: '1'} :
{ height: '100%', width: '100%', marginLeft: '0px', opacity: '1' };
$scndContainer.stop().animate(dwnCss, { duration: tdata.speed });
window.setTimeout(function () {
$firstContainer.stop().animate(dwnCss2, { duration: tdata.speed });
if (swapBackSource) {
var isRandom = stgs.backIsRandom;
var index = staticIndexBack;
if (isRandom) {
//make sure the random bag is ready
if (backRandomBag.length == 0) {
for (var i = 0; i < stgs.backImages.length; i++) {
//make sure there's not an immediate repeat
if (i != prevBackIndex || stgs.backImages.length == 1)
backRandomBag[i] = i;
}
backRandomBag = privMethods.shuffleArray(backRandomBag);
}
index = backRandomBag.pop();
prevBackIndex = index;
}
privMethods.handleSwap($scndContainer, false, stgs, index);
staticIndexBack += 1;
if (staticIndexBack >= stgs.backImages.length) {
staticIndexBack = 0;
}
}
tdata.isReversed = !tdata.isReversed;
stgs.animationComplete(tdata, $firstContainer, $scndContainer);
if (callback != null)
callback();
}, tdata.speed);
}
}
};