-
Notifications
You must be signed in to change notification settings - Fork 4
/
kelmu.js
104 lines (88 loc) · 3.97 KB
/
kelmu.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
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
(function($) {
$(function() {
'use strict';
if (window.JSVEE === undefined) {
return;
}
const _ = typeof(window._) === "function" ?
window._ :
function(msg) {
return msg;
};
var runToLineActive = false;
var annotations = window.kelmu;
if (annotations) {
JSVEE.afterInitialization(function() {
var self = this;
annotations.registerCallback(self.animationId,
function(action, parameter) {
if (action === 'skip') {
JSVEE.utils.ui.setStatusText(self.area, _('Moving forward'));
self.state.stepsToRun = +parameter;
self.state.animationsDisabled = true;
self.state.reEnableAnimations = true;
} else if (action === 'runToLine') {
JSVEE.utils.ui.setStatusText(self.area, _('Moving forward'));
self.state.runToLine = +parameter;
self.state.reEnableAnimations = true;
runToLineActive = true;
self.makeStep();
} else if (action === 'skipToLine') {
JSVEE.utils.ui.setStatusText(self.area, _('Moving forward'));
self.state.runToLine = +parameter;
self.state.reEnableAnimations = true;
self.state.animationsDisabled = true;
runToLineActive = true;
self.makeStep();
} else if (action === 'hideControls') {
self.area.find('.jsvee-controls-area').hide();
} else if (action === 'showSequence') {
self.disableStateSave = true;
} else if (action === 'showControls') {
self.area.find('.jsvee-controls-area').show();
} else if (action === 'getCapabilities') {
annotations.sendMessage(self.animationId, 'animationCapabilities', null, ['animationReady']);
} else if (action === 'getAnimationLength') {
annotations.sendMessage(self.animationId, 'animationLength', self.animationLength);
} else if (action === 'getButtonDefinitions') {
annotations.sendMessage(self.animationId, 'buttonDefinitions', null, {
'step': '.jsvee-step',
'redo': '.jsvee-redo',
'undo': '.jsvee-undo',
'begin': '.jsvee-begin'
});
} else if (action === 'postponeEnd') {
var statusArea = self.area.find('.jsvee-status-area');
statusArea.text(statusArea.text()
.substring(0, statusArea.text().indexOf(JSVEE.messages.animationEnded())));
} else if (action === 'lastSubstepShown') {
var statusArea = self.area.find('.jsvee-status-area');
statusArea.text(statusArea.text() + JSVEE.messages.animationEnded());
} else if (action === 'getCurrentStep') {
annotations.sendMessage(self.animationId, 'currentStep', (self.initSkippedSteps || 0) + self.state.stepNumberAll);
} else if (action === 'getCurrentLine') {
annotations.sendMessage(self.animationId, 'currentLine', self.area.find('.jsvee-code-area').attr(
'data-line'));
}
});
var name = self.area.attr('data-kelmu-id') || self.area.attr('data-id');
if (window.kelmu && window.kelmu.data[name]) {
setTimeout(function() {
window.kelmu.initAnnotations(self.area, name);
}, 200);
}
});
JSVEE.afterEachStep(true, function(instr) {
if (!this.actionsRunning && runToLineActive) {
annotations.sendMessage(this.animationId, 'currentStep', (this.initSkippedSteps || 0) + this.state.stepNumberAll);
}
if (!this.actionsRunning || !this.state.animationsDisabled) {
annotations.sendMessage(this.animationId, 'animationReady');
}
if (this.hasEnded()) {
annotations.sendMessage(this.animationId, 'animationEnded');
}
});
}
});
})(jQuery);