blob: 2d60518741451a4b69c7db6da540cc1c3c7b4c66 (
plain)
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
/**
* @fileOverview a scoreboard widget
* @author Bryan Berry <bryan@olenepal.org>
* uses MIT License
*/
(function($){
// This is a dummy function, just here as placeholder to
// to make the jsdoc tool happy
/** @name $.ui.scoreboard
* @namespace Scoreboard widget
*/
$.ui.feedback = function(){};
$.widget('ui.feedback',
/** @lends $.ui.feedback.prototype */
{
correct: function(){
this.$correct.css('display','block').fadeOut(3000);
if (Karma && Karma.audio && Karma.audio.correct){
Karma.audio.correct.play();
}
},
incorrect: function(){
this.$incorrect.css('display','block').fadeOut(3000);
if (Karma && Karma.audio && Karma.audio.incorrect){
Karma.audio.incorrect.play();
}
},
_init : function(){
var self = this;
this.element
.addClass('ui-feedback')
.css({position:'absolute',
top: '40%', left: '40%'});
this.$correct = $('<div></div>')
.addClass('ui-feedback-correct')
.appendTo(this.element);
this.$incorrect = $('<div></div>')
.addClass('ui-feedback-incorrect')
.appendTo(this.element);
$('body')
.bind('feedbackCorrect', function(){
self.correct();
})
.bind('feedbackIncorrect', function(){
self.incorrect();
});
},
/** Removes the scoreboard widget and all related data from the DOM */
destroy : function(){
this.element.remove();
$.widget.prototype.destroy.apply(this, arguments);
}
});
$.ui.scoreboard.getter = [];
/** Default settings for the scoreboard widget
* @namespace Default settings for the scoreboard widget
* @extends $.ui.scoreboard
*/
$.ui.feedback.defaults = {
};
})(jQuery);
|