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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
enyo.kind({
name: "biblez.dataView",
kind: "enyo.FittableRows",
fit: true,
events: {
onBack: "",
onVerse: ""
},
published: {
section: ""
},
components: [
{name: "messagePopup", kind: "onyx.Popup", centered: true, floating: true, classes: "message-popup"},
{kind: "onyx.MoreToolbar", layoutKind:"FittableColumnsLayout", components: [
{kind: "onyx.IconButton", src: "assets/back.png", ontap: "handleBack"},
{kind: "onyx.RadioGroup", onActivate:"sectionActivated", classes: "center", fit: true, defaultKind: "onyx.IconButton", components: [
{name: "rbBm", src: "assets/bookmarksTB.png", section: "bookmarks", style: "margin: 0 10px;"},
{name: "rbNotes", src: "assets/notesTB.png", section: "notes", style: "margin: 0 10px;"},
{name: "rbHl", src: "assets/highlightsTB.png", section: "highlights", style: "margin: 0 10px;"}
]},
]},
{name: "noData", classes: "center", style: "margin-top: 10px;", showing: false},
{name: "dataList", kind: "List", fit: true, touch: true, onSetupItem: "setupItem", components: [
{name: "item", classes: "item", ontap: "handleListTap", components: [
{kind: "enyo.FittableRows", components: [
{name: "itemOsis", classes: ""},
{name: "itemText", classes: "item-text", allowHtml: true}
]}
]}
]}
],
data: [],
sectionActivated: function (inSender, inEvent) {
if (inEvent.originator.getActive()) {
this.setSection(inEvent.originator.section);
}
return true;
},
sectionChanged: function (inSender, inEvent) {
if (this.section === "bookmarks") {
this.$.rbBm.setActive(true);
api.getAllBookmarks(enyo.bind(this, function (inError, inData) {
if(!inError) {
this.data = inData;
this.$.dataList.setCount(this.data.length);
if(this.data.length === 0) {
this.$.noData.show();
this.$.noData.setContent($L("No Bookmarks.") + " " + $L("Tap on a verse number to add one."));
} else
this.$.noData.hide();
this.$.dataList.refresh();
} else
this.handleError(inError);
}));
} else if (this.section === "notes") {
this.$.rbNotes.setActive(true);
api.getAllNotes(enyo.bind(this, function (inError, inData) {
if(!inError) {
this.data = inData;
this.$.dataList.setCount(this.data.length);
if(this.data.length === 0) {
this.$.noData.show();
this.$.noData.setContent($L("No Bookmarks.") + " " + $L("Tap on a verse number to add one."));
} else
this.$.noData.hide();
this.$.dataList.refresh();
} else
this.handleError(inError);
}));
} else if (this.section === "highlights") {
this.$.rbHl.setActive(true);
api.getAllHighlights(enyo.bind(this, function (inError, inData) {
if(!inError) {
this.data = inData;
if(this.data.length === 0) {
this.$.noData.show();
this.$.noData.setContent($L("No Bookmarks.") + " " + $L("Tap on a verse number to add one."));
} else
this.$.noData.hide();
this.$.dataList.setCount(this.data.length);
this.$.dataList.refresh();
} else
this.handleError(inError);
}));
}
},
setupItem: function(inSender, inEvent) {
var data = this.data[inEvent.index];
this.$.itemOsis.setContent(api.formatOsis(data.osisRef));
if(this.section === "highlights")
this.$.item.applyStyle("background-color", data.color);
else
this.$.item.applyStyle("background-color", null);
if(this.section === "notes")
this.$.itemText.setContent(data.text);
else
this.$.itemText.setContent("");
//this.$.index.setContent(inEvent.index);
},
handleListTap: function (inSender, inEvent) {
this.doVerse({osisRef: this.data[inEvent.index].osisRef});
},
handleBack: function() {
this.doBack();
},
handleError: function (inMessage) {
if (inMessage.message)
inMessage = inMessage.message;
this.$.messagePopup.setContent(inMessage);
this.$.messagePopup.show();
}
});
|