Team:Marburg/Template:Header

From 2013.igem.org

(Difference between revisions)
m
m
Line 347: Line 347:
function log() {
function log() {
/*global console */
/*global console */
-
if (window.console && console.log)
+
if (window.console AND console.log)
console.log('[cycle] ' + Array.prototype.join.call(arguments,' '));
console.log('[cycle] ' + Array.prototype.join.call(arguments,' '));
}
}
Line 369: Line 369:
// in 1.3+ we can fix mistakes with the ready state
// in 1.3+ we can fix mistakes with the ready state
-
if (this.length === 0 && options != 'stop') {
+
if (this.length === 0 AND options != 'stop') {
-
if (!$.isReady && o.s) {
+
if (!$.isReady AND o.s) {
log('DOM not ready, queuing slideshow');
log('DOM not ready, queuing slideshow');
$(function() {
$(function() {
Line 427: Line 427:
return;
return;
var paused = !!cont.cyclePause;
var paused = !!cont.cyclePause;
-
if (paused && opts.paused)
+
if (paused AND opts.paused)
opts.paused(cont, opts, byHover, onPager);
opts.paused(cont, opts, byHover, onPager);
-
else if (!paused && opts.resumed)
+
else if (!paused AND opts.resumed)
opts.resumed(cont, opts, byHover, onPager);
opts.resumed(cont, opts, byHover, onPager);
}
}
Line 511: Line 511:
function checkInstantResume(isPaused, arg2, cont) {
function checkInstantResume(isPaused, arg2, cont) {
-
if (!isPaused && arg2 === true) { // resume now!
+
if (!isPaused AND arg2 === true) { // resume now!
var options = $(cont).data('cycle.opts');
var options = $(cont).data('cycle.opts');
if (!options) {
if (!options) {
Line 527: Line 527:
function removeFilter(el, opts) {
function removeFilter(el, opts) {
-
if (!$.support.opacity && opts.cleartype && el.style.filter) {
+
if (!$.support.opacity AND opts.cleartype AND el.style.filter) {
try { el.style.removeAttribute('filter'); }
try { el.style.removeAttribute('filter'); }
catch(smother) {} // handle old opera versions
catch(smother) {} // handle old opera versions
Line 570: Line 570:
// push some after callbacks
// push some after callbacks
-
if (!$.support.opacity && opts.cleartype)
+
if (!$.support.opacity AND opts.cleartype)
opts.after.push(function() { removeFilter(this, opts); });
opts.after.push(function() { removeFilter(this, opts); });
if (opts.continuous)
if (opts.continuous)
Line 578: Line 578:
// clearType corrections
// clearType corrections
-
if (!$.support.opacity && opts.cleartype && !opts.cleartypeNoBg)
+
if (!$.support.opacity AND opts.cleartype AND !opts.cleartypeNoBg)
clearTypeFix($slides);
clearTypeFix($slides);
Line 586: Line 586:
if (opts.width)
if (opts.width)
$cont.width(opts.width);
$cont.width(opts.width);
-
if (opts.height && opts.height != 'auto')
+
if (opts.height AND opts.height != 'auto')
$cont.height(opts.height);
$cont.height(opts.height);
Line 644: Line 644:
        if (opts.width)
        if (opts.width)
            $slides.width(opts.width);
            $slides.width(opts.width);
-
        if (opts.height && opts.height != 'auto')
+
        if (opts.height AND opts.height != 'auto')
            $slides.height(opts.height);
            $slides.height(opts.height);
} else {
} else {
Line 650: Line 650:
var $slide = $(this);
var $slide = $(this);
var ratio = (opts.aspect === true) ? $slide.width()/$slide.height() : opts.aspect;
var ratio = (opts.aspect === true) ? $slide.width()/$slide.height() : opts.aspect;
-
if( opts.width && $slide.width() != opts.width ) {
+
if( opts.width AND $slide.width() != opts.width ) {
$slide.width( opts.width );
$slide.width( opts.width );
$slide.height( opts.width / ratio );
$slide.height( opts.width / ratio );
}
}
-
if( opts.height && $slide.height() < opts.height ) {
+
if( opts.height AND $slide.height() < opts.height ) {
$slide.height( opts.height );
$slide.height( opts.height );
$slide.width( opts.height * ratio );
$slide.width( opts.height * ratio );
Line 663: Line 663:
}
}
-
if (opts.center && ((!opts.fit) || opts.aspect)) {
+
if (opts.center AND ((!opts.fit) || opts.aspect)) {
$slides.each(function(){
$slides.each(function(){
var $slide = $(this);
var $slide = $(this);
Line 677: Line 677:
}
}
-
if (opts.center && !opts.fit && !opts.slideResize) {
+
if (opts.center AND !opts.fit AND !opts.slideResize) {
$slides.each(function(){
$slides.each(function(){
var $slide = $(this);
var $slide = $(this);
Line 688: Line 688:
// stretch container
// stretch container
-
var reshape = (opts.containerResize || opts.containerResizeHeight) && $cont.innerHeight() < 1;
+
var reshape = (opts.containerResize || opts.containerResizeHeight) AND $cont.innerHeight() < 1;
if (reshape) { // do this only if container has no size http://tinyurl.com/da2oa9
if (reshape) { // do this only if container has no size http://tinyurl.com/da2oa9
var maxw = 0, maxh = 0;
var maxw = 0, maxh = 0;
Line 698: Line 698:
maxh = h > maxh ? h : maxh;
maxh = h > maxh ? h : maxh;
}
}
-
if (opts.containerResize && maxw > 0 && maxh > 0)
+
if (opts.containerResize AND maxw > 0 AND maxh > 0)
$cont.css({width:maxw+'px',height:maxh+'px'});
$cont.css({width:maxw+'px',height:maxh+'px'});
-
if (opts.containerResizeHeight && maxh > 0)
+
if (opts.containerResizeHeight AND maxh > 0)
$cont.css({height:maxh+'px'});
$cont.css({height:maxh+'px'});
}
}
Line 726: Line 726:
// try to get height/width of each slide
// try to get height/width of each slide
var $el = $(this);
var $el = $(this);
-
this.cycleH = (opts.fit && opts.height) ? opts.height : ($el.height() || this.offsetHeight || this.height || $el.attr('height') || 0);
+
this.cycleH = (opts.fit AND opts.height) ? opts.height : ($el.height() || this.offsetHeight || this.height || $el.attr('height') || 0);
-
this.cycleW = (opts.fit && opts.width) ? opts.width : ($el.width() || this.offsetWidth || this.width || $el.attr('width') || 0);
+
this.cycleW = (opts.fit AND opts.width) ? opts.width : ($el.width() || this.offsetWidth || this.width || $el.attr('width') || 0);
if ( $el.is('img') ) {
if ( $el.is('img') ) {
-
var loading = (this.cycleH === 0 && this.cycleW === 0 && !this.complete);
+
var loading = (this.cycleH === 0 AND this.cycleW === 0 AND !this.complete);
// don't requeue for images that are still loading but have a valid size
// don't requeue for images that are still loading but have a valid size
if (loading) {
if (loading) {
-
if (o.s && opts.requeueOnImageNotLoaded && ++options.requeueAttempts < 100) { // track retry count so we don't loop forever
+
if (o.s AND opts.requeueOnImageNotLoaded AND ++options.requeueAttempts < 100) { // track retry count so we don't loop forever
log(options.requeueAttempts,' - img slide not loaded, requeuing slideshow: ', this.src, this.cycleW, this.cycleH);
log(options.requeueAttempts,' - img slide not loaded, requeuing slideshow: ', this.src, this.cycleW, this.cycleH);
setTimeout(function() {$(o.s,o.c).cycle(options);}, opts.requeueTimeout);
setTimeout(function() {$(o.s,o.c).cycle(options);}, opts.requeueTimeout);
Line 795: Line 795:
if ($.isFunction(init))
if ($.isFunction(init))
init($cont, $slides, opts);
init($cont, $slides, opts);
-
else if (opts.fx != 'custom' && !opts.multiFx) {
+
else if (opts.fx != 'custom' AND !opts.multiFx) {
log('unknown transition: ' + opts.fx,'; slideshow terminating');
log('unknown transition: ' + opts.fx,'; slideshow terminating');
return false;
return false;
Line 860: Line 860:
if (txs.hasOwnProperty(p)) {
if (txs.hasOwnProperty(p)) {
tx = txs[p];
tx = txs[p];
-
if (txs.hasOwnProperty(p) && $.isFunction(tx))
+
if (txs.hasOwnProperty(p) AND $.isFunction(tx))
opts.fxs.push(p);
opts.fxs.push(p);
}
}
}
}
}
}
-
if (opts.multiFx && opts.randomizeEffects) {
+
if (opts.multiFx AND opts.randomizeEffects) {
// munge the fxs array to make effect selection random
// munge the fxs array to make effect selection random
var r1 = Math.floor(Math.random() * 20) + 30;
var r1 = Math.floor(Math.random() * 20) + 30;
Line 902: Line 902:
}
}
-
if (!$.support.opacity && opts.cleartype && !opts.cleartypeNoBg)
+
if (!$.support.opacity AND opts.cleartype AND !opts.cleartypeNoBg)
clearTypeFix($s);
clearTypeFix($s);
-
if (opts.fit && opts.width)
+
if (opts.fit AND opts.width)
$s.width(opts.width);
$s.width(opts.width);
-
if (opts.fit && opts.height && opts.height != 'auto')
+
if (opts.fit AND opts.height AND opts.height != 'auto')
$s.height(opts.height);
$s.height(opts.height);
-
s.cycleH = (opts.fit && opts.height) ? opts.height : $s.height();
+
s.cycleH = (opts.fit AND opts.height) ? opts.height : $s.height();
-
s.cycleW = (opts.fit && opts.width) ? opts.width : $s.width();
+
s.cycleW = (opts.fit AND opts.width) ? opts.width : $s.width();
$s.css(opts.cssBefore);
$s.css(opts.cssBefore);
Line 947: Line 947:
// opts.busy is true if we're in the middle of an animation
// opts.busy is true if we're in the middle of an animation
-
if (manual && opts.busy && opts.manualTrump) {
+
if (manual AND opts.busy AND opts.manualTrump) {
// let manual transitions requests trump active ones
// let manual transitions requests trump active ones
debug('manualTrump in go(), stopping active transition');
debug('manualTrump in go(), stopping active transition');
Line 963: Line 963:
// stop cycling if we have an outstanding stop request
// stop cycling if we have an outstanding stop request
-
if (p.cycleStop != opts.stopCount || p.cycleTimeout === 0 && !manual)
+
if (p.cycleStop != opts.stopCount || p.cycleTimeout === 0 AND !manual)
return;
return;
// check to see if we should stop cycling based on autostop options
// check to see if we should stop cycling based on autostop options
-
if (!manual && !p.cyclePause && !opts.bounce &&
+
if (!manual AND !p.cyclePause AND !opts.bounce AND
-
((opts.autostop && (--opts.countdown <= 0)) ||
+
((opts.autostop AND (--opts.countdown <= 0)) ||
-
(opts.nowrap && !opts.random && opts.nextSlide < opts.currSlide))) {
+
(opts.nowrap AND !opts.random AND opts.nextSlide < opts.currSlide))) {
if (opts.end)
if (opts.end)
opts.end(opts);
opts.end(opts);
Line 977: Line 977:
// if slideshow is paused, only transition on a manual trigger
// if slideshow is paused, only transition on a manual trigger
var changed = false;
var changed = false;
-
if ((manual || !p.cyclePause) && (opts.nextSlide != opts.currSlide)) {
+
if ((manual || !p.cyclePause) AND (opts.nextSlide != opts.currSlide)) {
changed = true;
changed = true;
var fx = opts.fx;
var fx = opts.fx;
Line 988: Line 988:
// support multiple transition types
// support multiple transition types
if (opts.multiFx) {
if (opts.multiFx) {
-
if (fwd && (opts.lastFx === undefined || ++opts.lastFx >= opts.fxs.length))
+
if (fwd AND (opts.lastFx === undefined || ++opts.lastFx >= opts.fxs.length))
opts.lastFx = 0;
opts.lastFx = 0;
-
else if (!fwd && (opts.lastFx === undefined || --opts.lastFx < 0))
+
else if (!fwd AND (opts.lastFx === undefined || --opts.lastFx < 0))
opts.lastFx = opts.fxs.length - 1;
opts.lastFx = opts.fxs.length - 1;
fx = opts.fxs[opts.lastFx];
fx = opts.fxs[opts.lastFx];
Line 1,028: Line 1,028:
opts.busy = 1;
opts.busy = 1;
if (opts.fxFn) // fx function provided?
if (opts.fxFn) // fx function provided?
-
opts.fxFn(curr, next, opts, after, fwd, manual && opts.fastOnEvent);
+
opts.fxFn(curr, next, opts, after, fwd, manual AND opts.fastOnEvent);
else if ($.isFunction($.fn.cycle[opts.fx])) // fx plugin ?
else if ($.isFunction($.fn.cycle[opts.fx])) // fx plugin ?
-
$.fn.cycle[opts.fx](curr, next, opts, after, fwd, manual && opts.fastOnEvent);
+
$.fn.cycle[opts.fx](curr, next, opts, after, fwd, manual AND opts.fastOnEvent);
else
else
-
$.fn.cycle.custom(curr, next, opts, after, fwd, manual && opts.fastOnEvent);
+
$.fn.cycle.custom(curr, next, opts, after, fwd, manual AND opts.fastOnEvent);
}
}
else {
else {
Line 1,054: Line 1,054:
else if (opts.backwards) {
else if (opts.backwards) {
roll = (opts.nextSlide - 1) < 0;
roll = (opts.nextSlide - 1) < 0;
-
if (roll && opts.bounce) {
+
if (roll AND opts.bounce) {
opts.backwards = !opts.backwards;
opts.backwards = !opts.backwards;
opts.nextSlide = 1;
opts.nextSlide = 1;
Line 1,066: Line 1,066:
else { // sequence
else { // sequence
roll = (opts.nextSlide + 1) == els.length;
roll = (opts.nextSlide + 1) == els.length;
-
if (roll && opts.bounce) {
+
if (roll AND opts.bounce) {
opts.backwards = !opts.backwards;
opts.backwards = !opts.backwards;
opts.nextSlide = els.length-2;
opts.nextSlide = els.length-2;
Line 1,077: Line 1,077:
}
}
}
}
-
if (changed && opts.pager)
+
if (changed AND opts.pager)
opts.updateActivePagerLink(opts.pager, opts.currSlide, opts.activePagerClass);
opts.updateActivePagerLink(opts.pager, opts.currSlide, opts.activePagerClass);
Line 1,083: Line 1,083:
// stage the next transition
// stage the next transition
var ms = 0, timeout = opts.timeout;
var ms = 0, timeout = opts.timeout;
-
if (opts.timeout && !opts.continuous) {
+
if (opts.timeout AND !opts.continuous) {
ms = getTimeout(els[opts.currSlide], els[opts.nextSlide], opts, fwd);
ms = getTimeout(els[opts.currSlide], els[opts.nextSlide], opts, fwd);
         if (opts.fx == 'shuffle')
         if (opts.fx == 'shuffle')
             ms -= opts.speedOut;
             ms -= opts.speedOut;
       }
       }
-
else if (opts.continuous && p.cyclePause) // continuous shows work off an after callback, not this timer logic
+
else if (opts.continuous AND p.cyclePause) // continuous shows work off an after callback, not this timer logic
ms = 10;
ms = 10;
if (ms > 0)
if (ms > 0)
Line 1,107: Line 1,107:
// call user provided calc fn
// call user provided calc fn
var t = opts.timeoutFn.call(curr,curr,next,opts,fwd);
var t = opts.timeoutFn.call(curr,curr,next,opts,fwd);
-
while (opts.fx != 'none' && (t - opts.speed) < 250) // sanitize timeout
+
while (opts.fx != 'none' AND (t - opts.speed) < 250) // sanitize timeout
t += opts.speed;
t += opts.speed;
debug('calculated timeout: ' + t + '; speed: ' + opts.speed);
debug('calculated timeout: ' + t + '; speed: ' + opts.speed);
Line 1,129: Line 1,129:
p.cycleTimeout = 0;
p.cycleTimeout = 0;
}
}
-
if (opts.random && val < 0) {
+
if (opts.random AND val < 0) {
// move back to the previously display slide
// move back to the previously display slide
opts.randomIndex--;
opts.randomIndex--;
Line 1,221: Line 1,221:
}
}
-
if ( ! /^click/.test(opts.pagerEvent) && !opts.allowPagerClickBubble)
+
if ( ! /^click/.test(opts.pagerEvent) AND !opts.allowPagerClickBubble)
$a.bind('click.cycle', function(){return false;}); // suppress click
$a.bind('click.cycle', function(){return false;}); // suppress click
Line 1,260: Line 1,260:
}
}
function getBg(e) {
function getBg(e) {
-
for ( ; e && e.nodeName.toLowerCase() != 'html'; e = e.parentNode) {
+
for ( ; e AND e.nodeName.toLowerCase() != 'html'; e = e.parentNode) {
var v = $.css(e,'background-color');
var v = $.css(e,'background-color');
-
if (v && v.indexOf('rgb') >= 0 ) {
+
if (v AND v.indexOf('rgb') >= 0 ) {
var rgb = v.match(/\d+/g);
var rgb = v.match(/\d+/g);
return '#'+ hex(rgb[0]) + hex(rgb[1]) + hex(rgb[2]);
return '#'+ hex(rgb[0]) + hex(rgb[1]) + hex(rgb[2]);
}
}
-
if (v && v != 'transparent')
+
if (v AND v != 'transparent')
return v;
return v;
}
}
Line 1,280: Line 1,280:
opts.cssBefore.opacity = 1;
opts.cssBefore.opacity = 1;
opts.cssBefore.display = 'block';
opts.cssBefore.display = 'block';
-
if (opts.slideResize && w !== false && next.cycleW > 0)
+
if (opts.slideResize AND w !== false AND next.cycleW > 0)
opts.cssBefore.width = next.cycleW;
opts.cssBefore.width = next.cycleW;
-
if (opts.slideResize && h !== false && next.cycleH > 0)
+
if (opts.slideResize AND h !== false AND next.cycleH > 0)
opts.cssBefore.height = next.cycleH;
opts.cssBefore.height = next.cycleH;
opts.cssAfter = opts.cssAfter || {};
opts.cssAfter = opts.cssAfter || {};
Line 1,811: Line 1,811:
$.fn.cycle.commonReset(curr,next,opts,true,true,true);
$.fn.cycle.commonReset(curr,next,opts,true,true,true);
// provide default toss settings if animOut not provided
// provide default toss settings if animOut not provided
-
if (!opts.animOut.left && !opts.animOut.top)
+
if (!opts.animOut.left AND !opts.animOut.top)
$.extend(opts.animOut, { left: w*2, top: -h/2, opacity: 0 });
$.extend(opts.animOut, { left: w*2, top: -h/2, opacity: 0 });
else
else

Revision as of 16:23, 20 September 2013