-
Notifications
You must be signed in to change notification settings - Fork 0
/
dashboard.js
86 lines (71 loc) · 2.13 KB
/
dashboard.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
(function(jQuery) {
var $ = jQuery;
if (Echo.AppServer.Dashboard.isDefined("AcmeCorporation.Apps.BlogPost.Dashboard")) return;
var dashboard = Echo.AppServer.Dashboard.manifest("AcmeCorporation.Apps.BlogPost.Dashboard");
dashboard.inherits = Echo.Utils.getComponent("Echo.AppServer.Dashboards.AppSettings");
dashboard.labels = {
"title": "Title",
"content": "Content",
"submit": "Save"
};
dashboard.templates.main =
'<div class="{class:container}">' +
'<label>{label:title}</label>' +
'<input type="text" class="{class:titleText}" value="{config:instance.config.title.text}">' +
'<select class="{class:titleSize}"></select>' +
'<label>{label:content}</label>' +
'<textarea class="{class:content}">{config:instance.config.content}</textarea><br>' +
'<button class="{class:submit}">{label:submit}</button>' +
'</div>';
dashboard.templates.option =
'<option value="{data:value}" {data:selected}>H{data:value}</option>';
dashboard.init = function() {
this.parent();
};
dashboard.renderers.titleSize = function(element) {
var self = this;
element.empty();
$.map([1, 2, 3], function(i) {
element.append(self.substitute({
"template": dashboard.templates.option,
"data": {
"value": i,
"selected": +self.config.get("instance.config.title.size") === i
? "selected" : ""
}
}));
});
return element;
};
dashboard.renderers.submit = function(element) {
var self = this;
return element.on("click", function() {
self.update({
"config": self._getConfig()
});
});
};
dashboard.methods.declareInitialConfig = function() {
return {
"title": {
"text": "Blog post Title",
"size": "2"
},
"content": "Blog post Content"
};
};
dashboard.methods._getConfig = function() {
return {
"title": {
"text": this.view.get("titleText").val(),
"size": this.view.get("titleSize").val()
},
"content": this.view.get("content").val()
};
};
dashboard.css =
'.{class:container} .{class:titleSize} { width: auto; }' +
'.{class:container} .{class:submit} { margin-left: 225px; }' +
'.{class:container} .{class:content} { width: 260px; resize: none; }';
Echo.AppServer.Dashboard.create(dashboard);
})(Echo.jQuery);