aboutsummaryrefslogtreecommitdiffstats
path: root/source/dataView.js
diff options
context:
space:
mode:
Diffstat (limited to 'source/dataView.js')
-rw-r--r--source/dataView.js103
1 files changed, 103 insertions, 0 deletions
diff --git a/source/dataView.js b/source/dataView.js
new file mode 100644
index 0000000..03995ae
--- /dev/null
+++ b/source/dataView.js
@@ -0,0 +1,103 @@
+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: "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.section = inEvent.originator.section;
+ this.sectionChanged();
+ }
+ },
+
+ 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);
+ 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);
+ 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;
+ 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();
+ }
+}); \ No newline at end of file