aboutsummaryrefslogtreecommitdiffstats
path: root/source/main.js
diff options
context:
space:
mode:
authorzefanja <zefanja@freenet.de>2013-12-26 20:23:50 +0700
committerzefanja <zefanja@freenet.de>2013-12-26 20:23:50 +0700
commit40f8a77ec7f0181afdcdc5f60fb81025198918c0 (patch)
treec383a4d7cd75ce001cc9ecc4d233a8ff985d94ca /source/main.js
parent93611890bc232a263df6459c3bdcbdf8c392e0b0 (diff)
downloadbiblez-ng-40f8a77ec7f0181afdcdc5f60fb81025198918c0.tar.gz
* finished basic bookmark support (add and remove)
* added new media files
Diffstat (limited to 'source/main.js')
-rw-r--r--source/main.js39
1 files changed, 34 insertions, 5 deletions
diff --git a/source/main.js b/source/main.js
index 4c1fa50..a6ae3bf 100644
--- a/source/main.js
+++ b/source/main.js
@@ -12,7 +12,7 @@ enyo.kind({
},
components:[
{kind: "Signals", onOrientationChange: "handleOrientation"},
- {kind: "biblez.versePopup", name: "versePopup"},
+ {kind: "biblez.versePopup", name: "versePopup", onBookmark: "handleBookmark"},
//{kind: "Signals", onbeforeunload: "handleUnload"},
{name: "messagePopup", kind: "onyx.Popup", centered: true, floating: true, classes: "message-popup"},
{kind: "onyx.MoreToolbar", name: "topTB", components: [
@@ -54,6 +54,7 @@ enyo.kind({
osis: "Matt.1",
label: "Matt 1"
},
+ userData: {},
modules: [],
panelIndex: 2,
settings: {id: "settings"},
@@ -173,7 +174,7 @@ enyo.kind({
} else
this.handleError(inError.message);
}));
- this.handleBookmarks(this.currentPassage.osis);
+ this.handleUserData(this.currentPassage.osis);
//console.log();
/*api.getAll(function (inError, inAll) {
console.log(inAll);
@@ -183,9 +184,27 @@ enyo.kind({
});*/
},
- handleBookmarks: function (inOsis) {
- this.currentModule.getVersesInChapter(inOsis);
+ handleUserData: function (inOsis) {
+ var vmax = this.currentModule.getVersesInChapter(inOsis);
+ api.getUserData(inOsis, vmax, enyo.bind(this, function (inError, inUserData) {
+ if(!inError) {
+ this.userData = inUserData;
+ Object.keys(inUserData).forEach(function (key) {
+ if(inUserData[key].bookmarkId) {
+ enyo.dom.byId(key).insertAdjacentHTML("beforeend", " <img id='img" + key + "' src='assets/bookmark.png' />");
+ }
+ });
+ }
+ }));
+
+ },
+ handleBookmark: function (inSender, inEvent) {
+ if(inEvent.action === "remove") {
+ var oldBmImg = enyo.dom.byId("img"+inEvent.osisRef);
+ oldBmImg.parentNode.removeChild(oldBmImg);
+ }
+ this.handleUserData(this.currentPassage.osis);
},
handleBcSelector: function (inSender, inEvent) {
@@ -223,9 +242,19 @@ enyo.kind({
}
if(attributes.type === "verseNum") {
this.$.versePopup.setOsisRef(attributes.osisRef);
+ if(this.userData.hasOwnProperty(attributes.osisRef))
+ if (this.userData[attributes.osisRef].bookmarkId) {
+ this.$.versePopup.setBmExists(true);
+ this.$.versePopup.setBmId(this.userData[attributes.osisRef].bookmarkId);
+ } else
+ this.$.versePopup.setBmExists(false);
+ else {
+ this.$.versePopup.setBmExists(false);
+ this.$.versePopup.setNoteExists(false);
+ }
+ this.$.versePopup.setLabels();
this.$.versePopup.showAtEvent(inEvent);
}
-
return true;
},