forked from sugarlabs/musicblocks
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathactivitypalette.js
More file actions
executable file
·80 lines (62 loc) · 2.5 KB
/
activitypalette.js
File metadata and controls
executable file
·80 lines (62 loc) · 2.5 KB
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
define(["sugar-web/graphics/palette",
"text!sugar-web/graphics/activitypalette.html"], function (palette, template) {
// 'use strict';
var activitypalette = {};
activitypalette.ActivityPalette = function (activityButton,
datastoreObject) {
palette.Palette.call(this, activityButton);
var activityTitle;
var descriptionLabel;
var descriptionBox;
this.getPalette().id = "activity-palette";
var containerElem = document.createElement('div');
containerElem.innerHTML = template;
this.setContent([containerElem]);
this.titleElem = containerElem.querySelector('#title');
this.descriptionElem = containerElem.querySelector('#description');
this.titleElem.onblur = function () {
datastoreObject.setMetadata({
"title": this.value,
"title_set_by_user": "1"
});
datastoreObject.save();
// Trigger reflective prompt
const reflectionPrompt = `What did you do? Why did you do it? What did you learn? What will you do next?`;
alert(reflectionPrompt);
// Reapply reflective prompt if not saved
if (!datastoreObject.getMetadata().title_set_by_user) {
alert(reflectionPrompt);
}
};
this.descriptionElem.onblur = function () {
datastoreObject.setMetadata({
"description": this.value
});
datastoreObject.save();
// Trigger reflective prompt
const reflectionPrompt = `What did you do? Why did you do it? What did you learn? What will you do next?`;
alert(reflectionPrompt);
// Reapply reflective prompt if not saved
if (!datastoreObject.getMetadata().description) {
alert(reflectionPrompt);
}
};
};
// Fill the text inputs with the received metadata.
var setTitleDescription = function (metadata) {
this.titleElem.value = metadata.title;
if (metadata.description !== undefined) {
this.descriptionElem.value = metadata.description;
}
};
activitypalette.ActivityPalette.prototype =
Object.create(palette.Palette.prototype, {
setTitleDescription: {
value: setTitleDescription,
enumerable: true,
configurable: true,
writable: true
}
});
return activitypalette;
});