view release on metacpan or search on metacpan
share/www/static/jquery.js view on Meta::CPAN
abort: function() {
if ( callback ) {
callback( undefined, true );
}
}
};
}
});
}
var fxNow, timerId,
rfxtypes = /^(?:toggle|show|hide)$/,
rfxnum = new RegExp( "^(?:([+-])=|)(" + core_pnum + ")([a-z%]*)$", "i" ),
rrun = /queueHooks$/,
animationPrefilters = [ defaultPrefilter ],
tweeners = {
"*": [function( prop, value ) {
var end, unit,
tween = this.createTween( prop, value ),
parts = rfxnum.exec( value ),
target = tween.cur(),
share/www/static/jquery.js view on Meta::CPAN
return result;
}
}
createTweens( animation, props );
if ( jQuery.isFunction( animation.opts.start ) ) {
animation.opts.start.call( elem, animation );
}
jQuery.fx.timer(
jQuery.extend( tick, {
elem: elem,
anim: animation,
queue: animation.opts.queue
})
);
// attach callbacks from options
return animation.progress( animation.opts.progress )
.done( animation.opts.done, animation.opts.complete )
share/www/static/jquery.js view on Meta::CPAN
clearQueue = type;
type = undefined;
}
if ( clearQueue && type !== false ) {
this.queue( type || "fx", [] );
}
return this.each(function() {
var dequeue = true,
index = type != null && type + "queueHooks",
timers = jQuery.timers,
data = jQuery._data( this );
if ( index ) {
if ( data[ index ] && data[ index ].stop ) {
stopQueue( data[ index ] );
}
} else {
for ( index in data ) {
if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
stopQueue( data[ index ] );
}
}
}
for ( index = timers.length; index--; ) {
if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) {
timers[ index ].anim.stop( gotoEnd );
dequeue = false;
timers.splice( index, 1 );
}
}
// start the next in the queue if the last step wasn't forced
// timers currently will call their complete callbacks, which will dequeue
// but only if they were gotoEnd
if ( dequeue || !gotoEnd ) {
jQuery.dequeue( this, type );
}
});
},
finish: function( type ) {
if ( type !== false ) {
type = type || "fx";
}
return this.each(function() {
var index,
data = jQuery._data( this ),
queue = data[ type + "queue" ],
hooks = data[ type + "queueHooks" ],
timers = jQuery.timers,
length = queue ? queue.length : 0;
// enable finishing flag on private data
data.finish = true;
// empty the queue first
jQuery.queue( this, type, [] );
if ( hooks && hooks.cur && hooks.cur.finish ) {
hooks.cur.finish.call( this );
}
// look for any active animations, and finish them
for ( index = timers.length; index--; ) {
if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
timers[ index ].anim.stop( true );
timers.splice( index, 1 );
}
}
// look for any animations in the old queue and finish them
for ( index = 0; index < length; index++ ) {
if ( queue[ index ] && queue[ index ].finish ) {
queue[ index ].finish.call( this );
}
}
share/www/static/jquery.js view on Meta::CPAN
jQuery.easing = {
linear: function( p ) {
return p;
},
swing: function( p ) {
return 0.5 - Math.cos( p*Math.PI ) / 2;
}
};
jQuery.timers = [];
jQuery.fx = Tween.prototype.init;
jQuery.fx.tick = function() {
var timer,
timers = jQuery.timers,
i = 0;
fxNow = jQuery.now();
for ( ; i < timers.length; i++ ) {
timer = timers[ i ];
// Checks the timer has not already been removed
if ( !timer() && timers[ i ] === timer ) {
timers.splice( i--, 1 );
}
}
if ( !timers.length ) {
jQuery.fx.stop();
}
fxNow = undefined;
};
jQuery.fx.timer = function( timer ) {
if ( timer() && jQuery.timers.push( timer ) ) {
jQuery.fx.start();
}
};
jQuery.fx.interval = 13;
jQuery.fx.start = function() {
if ( !timerId ) {
timerId = setInterval( jQuery.fx.tick, jQuery.fx.interval );
}
};
jQuery.fx.stop = function() {
clearInterval( timerId );
timerId = null;
};
jQuery.fx.speeds = {
slow: 600,
fast: 200,
// Default speed
_default: 400
};
// Back Compat <1.8 extension point
jQuery.fx.step = {};
if ( jQuery.expr && jQuery.expr.filters ) {
jQuery.expr.filters.animated = function( elem ) {
return jQuery.grep(jQuery.timers, function( fn ) {
return elem === fn.elem;
}).length;
};
}
jQuery.fn.offset = function( options ) {
if ( arguments.length ) {
return options === undefined ?
this :
this.each(function( i ) {
jQuery.offset.setOffset( this, options, i );
t/testlib/StatusStorage/AEDelayed.pm view on Meta::CPAN
my $self = bless {%args}, $class;
return $self;
}
sub _delayed_call {
my ($self, @args) = @_;
my $method;
$method = (caller(1))[3];
$method =~ s/^.*:://g;
my $delay = $self->{delay_sec} || 0;
my $w; $w = AnyEvent->timer(
after => $delay,
cb => sub {
undef $w;
$self->{backend}->$method(@args);
}
);
}
sub get_statuses { my $self = shift; $self->_delayed_call(@_) }
sub put_statuses { my $self = shift; $self->_delayed_call(@_) }
xt/js/message_banner.html view on Meta::CPAN
notStrictEqual($msg_span.css('display'), "none", "message displayed");
strictEqual($msg_span.text(), message, "message content OK");
}
function testNoMessage() {
var $msg_children =
strictEqual($("#mb").css("display"), "none", "message banner hidden");
}
test("MessageBanner", function() {
var faketimer = sinon.useFakeTimers();
var mb = new bb.MessageBanner("#mb");
ok(defined(mb), "MessageBanner created");
mb.show("normal message");
testMessage("normal", "normal message");
mb.show("error message", "error");
testMessage("error", "error message");
faketimer.tick(3000);
testMessage("error", "error message");
faketimer.tick(4000);
testNoMessage();
mb.show("message", null, 500);
testMessage("normal", "message");
faketimer.tick(2000);
testNoMessage();
faketimer.restore();
});
</script>
</body>
</html>
xt/js/sinon.js view on Meta::CPAN
if (commonJSModule) {
module.exports = collection;
} else {
sinon.collection = collection;
}
}(typeof sinon == "object" && sinon || null));
/*jslint eqeqeq: false, plusplus: false, evil: true, onevar: false, browser: true, forin: false*/
/*global module, require, window*/
/**
* Fake timer API
* setTimeout
* setInterval
* clearTimeout
* clearInterval
* tick
* reset
* Date
*
* Inspired by jsUnitMockTimeOut from JsUnit
*
xt/js/sinon.js view on Meta::CPAN
throw new TypeError("now should be milliseconds since UNIX epoch");
}
return clock;
},
setTimeout: function setTimeout(callback, timeout) {
return addTimer.call(this, arguments, false);
},
clearTimeout: function clearTimeout(timerId) {
if (!this.timeouts) {
this.timeouts = [];
}
if (timerId in this.timeouts) {
delete this.timeouts[timerId];
}
},
setInterval: function setInterval(callback, timeout) {
return addTimer.call(this, arguments, true);
},
clearInterval: function clearInterval(timerId) {
this.clearTimeout(timerId);
},
tick: function tick(ms) {
ms = typeof ms == "number" ? ms : parseTime(ms);
var tickFrom = this.now, tickTo = this.now + ms, previous = this.now;
var timer = this.firstTimerInRange(tickFrom, tickTo);
var firstException;
while (timer && tickFrom <= tickTo) {
if (this.timeouts[timer.id]) {
tickFrom = this.now = timer.callAt;
try {
this.callTimer(timer);
} catch (e) {
firstException = firstException || e;
}
}
timer = this.firstTimerInRange(previous, tickTo);
previous = tickFrom;
}
this.now = tickTo;
if (firstException) {
throw firstException;
}
return this.now;
},
firstTimerInRange: function (from, to) {
var timer, smallest, originalTimer;
for (var id in this.timeouts) {
if (this.timeouts.hasOwnProperty(id)) {
if (this.timeouts[id].callAt < from || this.timeouts[id].callAt > to) {
continue;
}
if (!smallest || this.timeouts[id].callAt < smallest) {
originalTimer = this.timeouts[id];
smallest = this.timeouts[id].callAt;
timer = {
func: this.timeouts[id].func,
callAt: this.timeouts[id].callAt,
interval: this.timeouts[id].interval,
id: this.timeouts[id].id,
invokeArgs: this.timeouts[id].invokeArgs
};
}
}
}
return timer || null;
},
callTimer: function (timer) {
if (typeof timer.interval == "number") {
this.timeouts[timer.id].callAt += timer.interval;
} else {
delete this.timeouts[timer.id];
}
try {
if (typeof timer.func == "function") {
timer.func.apply(null, timer.invokeArgs);
} else {
eval(timer.func);
}
} catch (e) {
var exception = e;
}
if (!this.timeouts[timer.id]) {
if (exception) {
throw exception;
}
return;
}
if (exception) {
throw exception;
}
},
xt/js/sinon.js view on Meta::CPAN
}
for (var i = 0, l = clock.methods.length; i < l; i++) {
stubGlobal(clock.methods[i], clock);
}
return clock;
};
}(typeof global != "undefined" && typeof global !== "function" ? global : this));
sinon.timers = {
setTimeout: setTimeout,
clearTimeout: clearTimeout,
setInterval: setInterval,
clearInterval: clearInterval,
Date: Date
};
if (typeof module == "object" && typeof require == "function") {
module.exports = sinon;
}
xt/js/sinon.js view on Meta::CPAN
}
};
}());
if (typeof module == "object" && typeof require == "function") {
module.exports = sinon;
}
/**
* @depend fake_server.js
* @depend fake_timers.js
*/
/*jslint browser: true, eqeqeq: false, onevar: false*/
/*global sinon*/
/**
* Add-on for sinon.fakeServer that automatically handles a fake timer along with
* the FakeXMLHttpRequest. The direct inspiration for this add-on is jQuery
* 1.3.x, which does not use xhr object's onreadystatehandler at all - instead,
* it polls the object for completion with setInterval. Dispite the direct
* motivation, there is nothing jQuery-specific in this file, so it can be used
* in any environment where the ajax implementation depends on setInterval or
* setTimeout.
*
* @author Christian Johansen (christian@cjohansen.no)
* @license BSD
*
xt/js/sinon.js view on Meta::CPAN
this.clock.restore();
}
return sinon.fakeServer.restore.apply(this, arguments);
};
}());
/**
* @depend ../sinon.js
* @depend collection.js
* @depend util/fake_timers.js
* @depend util/fake_server_with_clock.js
*/
/*jslint eqeqeq: false, onevar: false, plusplus: false*/
/*global require, module*/
/**
* Manages fake collections as well as fake utilities such as Sinon's
* timers and fake XHR implementation in one convenient object.
*
* @author Christian Johansen (christian@cjohansen.no)
* @license BSD
*
* Copyright (c) 2010-2013 Christian Johansen
*/
if (typeof module == "object" && typeof require == "function") {
var sinon = require("../sinon");
sinon.extend(sinon, require("./util/fake_timers"));
}
(function () {
var push = [].push;
function exposeValue(sandbox, config, key, value) {
if (!value) {
return;
}
xt/js/utils.html view on Meta::CPAN
<div id="qunit-fixture"></div>
<script src="qunit.js"></script>
<script src="sinon.js"></script>
<script src="../../share/www/static/jquery.js"></script>
<script src="../../share/www/static/q.js"></script>
<script src="../../share/www/static/busybird.js"></script>
<script type="text/javascript">
"use strict";
var is = strictEqual;
var faketimer;
function fakeTimer() {
if(defined(faketimer)) {
faketimer.restore();
}
faketimer = sinon.useFakeTimers();
}
var fakeserver;
// SlowStartServer starts slowly.
// At first it responds with 404 for fail_num times.
// After that it starts responding with 200.
//
// @param fail_num Number of failed responses.
// @param fail_code HTTP erro code. It's 404 by default.
xt/js/utils.html view on Meta::CPAN
fakeTimer();
var pending = bb.ajaxRetry({url: "/"});
pending.promise.then(
function(data) { res = data },
function() { ok(false, "the ajax call should not be an error.") }
);
ok(!defined(res), "response is not returned yet");
is(fakeserver.pendingNum(), 1, "1 request pending");
fakeserver.respond();
is(fakeserver.pendingNum(), 0, "0 request pending");
faketimer.tick(200);
is(fakeserver.pendingNum(), 0, "0 request pending (not yet requested)");
faketimer.tick(200000);
is(fakeserver.pendingNum(), 1, "1 request pending");
fakeserver.respond();
faketimer.tick(1000);
is(fakeserver.pendingNum(), 0, "0 request pending (retry backoff)");
faketimer.tick(200000);
is(fakeserver.pendingNum(), 1, "1 request pending");
fakeserver.respond();
faketimer.tick(200000);
is(fakeserver.pendingNum(), 1, "1 request pending");
fakeserver.respond();
faketimer.tick(200000);
is(fakeserver.pendingNum(), 1, "1 request pending");
fakeserver.respond();
faketimer.tick(200000);
is(fakeserver.pendingNum(), 1, "1 request pending");
faketimer.restore();
Q.fcall(function() {
ok(!defined(res), "successful response is not returned yet");
fakeserver.respond();
return pending.promise;
}).then(function(data) {
is(res, "5", "response received at count = 5");
}, function(reason) {
ok(false, "ajaxRetry should succeed: " + reason);
}).then(function() {
fakeserver.restore();
xt/js/utils.html view on Meta::CPAN
});
$.each([400, 401, 403, 500, 501, 503], function(i, code) {
asyncTest("ajaxRetry (code = "+ code +")", function() {
fakeserver = new SlowStartServer(100, code);
fakeTimer();
var pending = bb.ajaxRetry({url: "/", tryMax: 2});
is(fakeserver.pendingNum(), 1, "1 request pending");
fakeserver.respond();
is(fakeserver.pendingNum(), 0, "0 request pending");
faketimer.tick(1000);
is(fakeserver.pendingNum(), 1, "retried request pending");
fakeserver.respond();
is(fakeserver.pendingNum(), 0, "0 request pending");
faketimer.tick(10000);
is(fakeserver.pendingNum(), 0, "no more request");
faketimer.restore();
pending.promise.then(function() {
ok(false, "ajaxRetry should not succeed");
}, function() {
ok(true, "ajaxRetry failure expected");
}).then(function() {
fakeserver.restore();
start();
});
});
});