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
|
enyo.kind({
name: "biblez.settings",
kind: "enyo.FittableRows",
fit: true,
events: {
onBack: "",
onChange: ""
},
components: [
{name: "messagePopup", kind: "onyx.Popup", scrim: true, centered: true, floating: true, classes: "message-popup"},
{kind: "onyx.MoreToolbar", components: [
{kind: "onyx.IconButton", src: "assets/back.png", ontap: "handleBack"},
{content: $L("Preferences")},
]},
{kind: "enyo.Scroller", touch: true, fit: true, components: [
{classes: "settings-container", components: [
{kind: "onyx.Groupbox", components: [
{kind: "onyx.GroupboxHeader", content: $L("General")},
{kind: "enyo.FittableColumns", classes: "settings-row", components: [
{content: $L("Enable Linebreak"), classes: "settings-item", fit: true},
{name: "tbLinebreak", kind: "onyx.ToggleButton", onChange: "toggleLinebreak"}
]}
]},
{tag: "br"},
{kind: "onyx.Groupbox", components: [
{kind: "onyx.GroupboxHeader", content: $L("Be careful!")},
{kind: "enyo.FittableRows", classes: "settings-row", components: [
{kind: "onyx.Button", content: "Delete all modules!", classes: "onyx-negative", style: "margin: 3px;", ontap: "deleteModules"},
{kind: "onyx.Button", content: "Delete all app data!", classes: "onyx-negative", style: "margin: 3px;", ontap: "deleteDatabases"}
]}
]},
]}
]}
],
handleBack: function() {
this.doBack();
},
setSettings: function () {
api.get("settings", enyo.bind(this, function(inError, inSettings) {
if(!inError) {
if(inSettings) {
this.$.tbLinebreak.value = inSettings.linebreak ? true : false;
this.$.tbLinebreak.updateVisualState();
}
}
}));
},
toggleLinebreak: function (inSender, inEvent) {
api.putSetting("linebreak", inSender.getValue(), enyo.bind(this, function (inError, inId) {
if(!inError)
this.doChange({setting: "linebreak", value: true});
}));
},
deleteModules: function () {
sword.dataMgr.clearDatabase();
},
deleteDatabases: function () {
api.deleteDatabases();
},
handleError: function (inMessage) {
if (inMessage.message)
inMessage = inMessage.message;
this.$.messagePopup.setContent(inMessage);
this.$.messagePopup.show();
}
});
|