From 1fe3475936da6c4a071283dc91af638a79c93d91 Mon Sep 17 00:00:00 2001 From: zefanja Date: Wed, 9 Apr 2014 10:21:23 +0700 Subject: * fixed reloads when opening a verse/footnote popup * fixed UI for CRUD actions on userData --- source/main.js | 15 +++++++-------- source/popup.js | 13 +++++++------ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/source/main.js b/source/main.js index 233573c..7cb52bd 100644 --- a/source/main.js +++ b/source/main.js @@ -74,7 +74,7 @@ enyo.kind({ ]}, {name: "mainPanel", kind: "Panels", draggable: false, /*index: 2, */fit: true, ondragfinish: "handleChangeChapter", onTransitionStart: "handlePanelIndex", arrangerKind: "LeftRightArranger", margin: 0, classes: "background", components: [ {name: "verseList", kind: "VerseList", touch: true, thumb: false, touchOverscroll: false, count: 0, onSetupItem: "setVerses", onScrollStop: "handleScrolling", components: [ - {name: "text", allowHtml: true, style: "display: inline;", ontap: "handleVerseTap"}, + {name: "text", allowHtml: true, style: "display: inline;", ontap: "handleVerseTap", onclick: "handleVerseTap"}, {name: "imgBm", tag: "img", style: "display: inline;", showing: false, src: "assets/bookmark.png"}, {name: "imgNote", tag: "img", style: "display: inline;", showing: false, src: "assets/note.png"} ]} @@ -374,7 +374,7 @@ enyo.kind({ noteKeys = []; api.getUserData(inOsis, vmax, enyo.bind(this, function (inError, inUserData) { if(!inError) { - this.userData = inUserData; + this.userData = api.extend(this.userData, inUserData); //console.log(this.userData); Object.keys(inUserData).forEach(enyo.bind(this, function (key) { if(inUserData[key].bookmarkId) { @@ -418,17 +418,16 @@ enyo.kind({ handleBookmark: function (inSender, inEvent) { if(inEvent.action === "remove") { - var oldBmImg = enyo.dom.byId("img"+inEvent.osisRef); - oldBmImg.parentNode.removeChild(oldBmImg); + this.updateVerses(inEvent.osisRef, {bookmark: false}); } - this.handleUserData(this.passage.osisRef); + this.handleUserData(inEvent.osisRef); }, handleHighlight: function (inSender, inEvent) { if(inEvent.action === "remove") { - enyo.dom.byId(inEvent.osisRef).style.backgroundColor = "transparent"; + this.updateVerses(inEvent.osisRef, {highlight: false}); } - this.handleUserData(this.passage.osisRef); + this.handleUserData(inEvent.osisRef); }, handleNoteTap: function (inSender, inEvent) { @@ -443,7 +442,7 @@ enyo.kind({ var oldNoteImg = enyo.dom.byId("note"+inEvent.osisRef); oldNoteImg.parentNode.removeChild(oldNoteImg); } - this.handleUserData(this.passage.osisRef); + this.handleUserData(inEvent.osisRef); }, handleBcSelector: function (inSender, inEvent) { diff --git a/source/popup.js b/source/popup.js index 1a5d42b..0255030 100644 --- a/source/popup.js +++ b/source/popup.js @@ -2,9 +2,8 @@ enyo.kind({ name: "biblez.versePopup", kind: "onyx.Popup", - modal: false, - scrimWhenModal: true, - scrim: true, + modal: true, + floating: true, classes: "verse-popup", events: { onBookmark: "", @@ -52,7 +51,7 @@ enyo.kind({ if (!this.bmExists) api.putBookmark({osisRef: this.osisRef}, enyo.bind(this, function (inError, inId) { if(!inError) { - this.doBookmark({action: "add"}); + this.doBookmark({action: "add", osisRef: this.osisRef}); } else console.log(inError); })); @@ -67,9 +66,11 @@ enyo.kind({ highlightVerse: function (inSender, inEvent) { this.hide(); - api.putHighlight({osisRef: this.osisRef, color: inSender.color}, enyo.bind(this, function (inError, inId) { + var obj = (this.hlExists) ? {id: this.hlId, osisRef: this.osisRef, color: inSender.color} : {osisRef: this.osisRef, color: inSender.color} + console.log(obj, this.hlId, this.hlExists); + api.putHighlight(obj, enyo.bind(this, function (inError, inId) { if(!inError) - this.doHighlight(); + this.doHighlight({osisRef: this.osisRef}); else console.log(inError); })); -- cgit