forked from nkallen/screw-unit
/
screw.events.js
42 lines (41 loc) · 1.22 KB
/
screw.events.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
(function($) {
$(Screw)
.bind('loaded', function() {
$('.describe, .it')
.click(function() {
document.location = location.href.split('?')[0] + '?' + $(this).fn('selector');
return false;
})
.focus(function() {
return $(this).addClass('focused');
})
.bind('scroll', function() {
document.body.scrollTop = $(this).offset().top;
});
$('.it')
.bind('enqueued', function() {
$(this).addClass('enqueued');
})
.bind('running', function() {
$(this).addClass('running');
})
.bind('passed', function() {
$(this).addClass('passed');
})
.bind('failed', function(e, reason) {
$(this)
.addClass('failed')
.append($('<p class="error"></p>').text(reason.toString()));
if (reason.fileName || reason.lineNumber) {
$(this)
.append($('<p class="error"></p>').text(reason.fileName + " : " + reason.lineNumber));
}
})
})
.bind('before', function() {
$('.status').text('Running...');
})
.bind('after', function() {
$('.status').fn('display')
})
})(jQuery);