aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--source/App.css7
-rw-r--r--source/App.js6
-rw-r--r--source/main.js67
-rw-r--r--source/notes.js2
-rw-r--r--source/popup.js3
-rw-r--r--source/settings.js8
6 files changed, 64 insertions, 29 deletions
diff --git a/source/App.css b/source/App.css
index d1e2ee9..6ebf8f5 100644
--- a/source/App.css
+++ b/source/App.css
@@ -22,6 +22,13 @@
}
}
+.toolbar-spinner {
+ width: 25px;
+ height: 25px;
+ display: inline-block;
+ background: url("../assets/spinner.gif") no-repeat 0 0;
+}
+
/* MAIN VIEW */
.verse-view {
margin: 10px;
diff --git a/source/App.js b/source/App.js
index 2a77749..ce85847 100644
--- a/source/App.js
+++ b/source/App.js
@@ -32,7 +32,7 @@ enyo.kind({
handleBack: function (inSender, inEvent) {
this.$.panel.selectPanelByName("main");
- if(inSender.name !== "bcSelector")
+ if(inSender.name !== "bcSelector" && inSender.name !== "notes" && inSender.name !== "settings")
enyo.asyncMethod(inSender, "destroy");
return true;
},
@@ -80,6 +80,8 @@ enyo.kind({
handleSettings: function (inSender, inEvent) {
this.$.main.handleSettings(inSender, inEvent);
+ enyo.asyncMethod(inSender, "destroy");
+ this.$.panel.selectPanelByName("main");
},
openNotes: function (inSender, inEvent) {
@@ -91,6 +93,8 @@ enyo.kind({
handleNote: function (inSender, inEvent) {
this.$.main.handleNote(inSender, inEvent);
+ enyo.asyncMethod(inSender, "destroy");
+ this.$.panel.selectPanelByName("main");
return true;
},
diff --git a/source/main.js b/source/main.js
index 7cb52bd..37cae3d 100644
--- a/source/main.js
+++ b/source/main.js
@@ -36,6 +36,7 @@ enyo.kind({
{kind: "onyx.Menu", maxHeight: "300", name: "historyMenu"}
]},
{fit: true},
+ {classes: "toolbar-spinner", name: "tbSpinner", showing: false},
{name: "actionSelector", kind: "onyx.MenuDecorator", onSelect: "actionSelected", components: [
{kind: "onyx.IconButton", src: "assets/menu.png"},
{kind: "onyx.Menu", name: "actionMenu", maxHeight: "300", style: "width: 200px;", components: [
@@ -76,8 +77,9 @@ enyo.kind({
{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", 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"}
+ {name: "imgNote", tag: "img", type: "note", style: "display: inline; margin: 0 3px;", showing: false, src: "assets/note.png", ontap: "handleVerseTap"}
]}
+
/*{},
{kind: "FittableColumns", noStretch: true, components: [
{fit: true},
@@ -134,12 +136,12 @@ enyo.kind({
this.getInstalledModules();
if(this.settings.fontSize) {
this.$.fontMenu.setFontSize(this.settings.fontSize);
- this.$.verseScroller.applyStyle("font-size", this.settings.fontSize + "em");
+ this.$.verseList.applyStyle("font-size", this.settings.fontSize + "em");
}
if(this.settings.font) {
this.$.fontMenu.setFont(this.settings.font);
if(this.settings.font !== "default")
- this.$.verseScroller.applyStyle("font-family", this.settings.font);
+ this.$.verseList.applyStyle("font-family", this.settings.font);
}
if(this.settings.history)
this.history = this.settings.history;
@@ -154,8 +156,7 @@ enyo.kind({
api.get("settings", enyo.bind(this, function(inError, inSettings) {
if(!inError) {
this.settings = (inSettings) ? inSettings: this.settings;
- if(inEvent.setting === "linebreak" || inEvent.setting === "footnotes" || inEvent.setting === "headings" || inEvent.setting === "crossReferences" || inEvent.setting === "introductions" || inEvent.setting === "woc")
- this.handlePassage();
+ this.handlePassage();
} else {
this.handleError("Couldn't load settings!");
}
@@ -166,7 +167,7 @@ enyo.kind({
sword.moduleMgr.getModules(enyo.bind(this, function(inError, inModules) {
if (!inError) {
if(inModules.length !== 0) {
- this.$.mainPanel.selectPanelByName("verseScroller");
+ this.$.mainPanel.selectPanelByName("verseList");
this.$.mainPanel.draggable = true;
this.$.topTB.show();
this.modules = inModules;
@@ -273,7 +274,7 @@ enyo.kind({
//console.log("PASSAGE", inOsis, this.passage);
//this.$.main.setContent("");
//this.$.spinner.start();
- var verseNumber = 0; //this.passage.verseNumber ? this.passage.verseNumber : 0;
+ var verseNumber = this.passage.verseNumber ? this.passage.verseNumber : 0;
if (typeof inOsis === "string") {
//BibleZ currently supports only Book.Chapter Osis passages in the mainView
@@ -296,7 +297,10 @@ enyo.kind({
this.verses.unshift({text: "<br><div class='caps'>" + this.passage.chapter + "</div>"});
this.$.verseList.setCount(this.verses.length);
this.$.verseList.refresh();
- this.$.verseList.scrollToStart();
+ if (verseNumber === 0)
+ this.$.verseList.scrollToStart();
+ else
+ this.$.verseList.scrollToRow(verseNumber+1);
this.renderHistory();
} else {
if(inError.code && inError.code === 123) {
@@ -317,21 +321,21 @@ enyo.kind({
setVerses: function (inSender, inEvent) {
var index = inEvent.index;
- //console.log(inEvent, index);
- this.$.text.setContent(this.verses[index].text);
+ var item = this.verses[index];
+ this.$.text.setContent(item.text);
//Bookmarks
- if(this.verses[index].bookmark)
+ if(item.bookmark)
this.$.imgBm.show();
else
this.$.imgBm.hide();
//Notes
- if(this.verses[index].note)
+ if(item.note)
this.$.imgNote.show();
else
this.$.imgNote.hide();
//Highlights
- if(this.verses[index].highlight)
- this.$.text.applyStyle("background-color", this.verses[index].color);
+ if(item.highlight)
+ this.$.text.applyStyle("background-color", item.color);
else
this.$.text.applyStyle("background-color", "none");
@@ -404,7 +408,7 @@ enyo.kind({
api.getNotes(noteKeys, enyo.bind(this, function (inError, inNotes) {
if(!inError) {
inNotes.forEach(enyo.bind(this, function (note) {
- this.updateVerses(note.osisRef, {note: true, type: "note", id: note.id});
+ this.updateVerses(note.osisRef, {note: true, type: "note", noteId: note.id});
}));
} else
this.handleError(inError);
@@ -437,10 +441,8 @@ enyo.kind({
},
handleNote: function (inSender, inEvent) {
- //console.log("handleNote", inEvent);
if(inEvent.action === "remove") {
- var oldNoteImg = enyo.dom.byId("note"+inEvent.osisRef);
- oldNoteImg.parentNode.removeChild(oldNoteImg);
+ this.updateVerses(inEvent.osisRef, {note: false});
}
this.handleUserData(inEvent.osisRef);
},
@@ -461,15 +463,17 @@ enyo.kind({
},
handleFont: function (inSender, inEvent) {
- this.$.main.applyStyle("font-family", inEvent.font);
+ this.$.verseList.applyStyle("font-family", inEvent.font);
+ this.$.verseList.reset();
api.putSetting("font", inEvent.font);
},
handleFontSize: function (inSender, inEvent) {
if(inEvent.font !== "default")
- this.$.main.applyStyle("font-size", inEvent.fontSize + "em");
+ this.$.verseList.applyStyle("font-size", inEvent.fontSize + "em");
else
- this.$.main.applyStyle("font-size", null);
+ this.$.verseList.applyStyle("font-size", null);
+ this.$.verseList.reset();
api.putSetting("fontSize", inEvent.fontSize);
},
@@ -490,7 +494,6 @@ enyo.kind({
handleVerseTap: function (inSender, inEvent) {
inEvent.preventDefault();
var attributes = {};
- //console.log(inEvent);
if(inEvent.target.href || inEvent.target.parentNode.href) {
var url = inEvent.target.href || inEvent.target.parentNode.href;
url.split("?")[1].split("&").forEach(function(item) {
@@ -527,14 +530,14 @@ enyo.kind({
this.$.versePopup.setLabels();
this.$.versePopup.showAtEvent(inEvent);
} else if (attributes.type === "note") {
- api.getNote(parseInt(attributes.id, 10), enyo.bind(this, function (inError, inNote) {
+ /*api.getNote(parseInt(attributes.noteId, 10), enyo.bind(this, function (inError, inNote) {
if(!inError) {
this.$.notePopup.setText(inNote.text);
this.$.notePopup.setOsisRef(inNote.osisRef);
this.$.notePopup.showAtEvent(inEvent);
} else
this.handleError(inError);
- }));
+ }));*/
} else if (attributes.type === "footnote") {
this.footnotes[attributes.osisRef].forEach(enyo.bind(this, function(item) {
if(item.n === attributes.n)
@@ -561,6 +564,18 @@ enyo.kind({
})
);
}
+
+ //Handle user notes
+ if(inSender.type === "note") {
+ api.getNote(parseInt(this.verses[inEvent.index].noteId, 10), enyo.bind(this, function (inError, inNote) {
+ if(!inError) {
+ this.$.notePopup.setText(inNote.text);
+ this.$.notePopup.setOsisRef(inNote.osisRef);
+ this.$.notePopup.showAtEvent(inEvent);
+ } else
+ this.handleError(inError);
+ }));
+ }
return false;
},
@@ -637,6 +652,8 @@ enyo.kind({
loadText: function (inOsis, inCallback) {
console.log(inOsis, this.passagePos);
+ this.$.tbSpinner.show();
+ this.$.topTB.resized();
this.currentModule.renderText(inOsis,
{
oneVersePerLine: this.settings.linebreak ? true : false,
@@ -650,6 +667,8 @@ enyo.kind({
enyo.bind(this, function (inError, inResult) {
//console.log(inError, inResult);
inCallback(inError, inResult);
+ this.$.tbSpinner.hide();
+ this.$.topTB.resized();
})
);
},
diff --git a/source/notes.js b/source/notes.js
index 5a39c23..d1bd1bc 100644
--- a/source/notes.js
+++ b/source/notes.js
@@ -58,6 +58,7 @@ enyo.kind({
api.putNote({id: this.noteId, text: this.$.noteInput.getValue().replace(/"/g, '&quot;'), osisRef: this.osisRef}, enyo.bind(this, function (inError, inId) {
if(!inError) {
this.doChange({action: "update", osisRef: this.osisRef});
+ this.doBack();
} else
console.log(inError);
}));
@@ -67,7 +68,6 @@ enyo.kind({
api.removeNote({id: this.noteId, osisRef: this.osisRef}, enyo.bind(this, function (inError) {
if(!inError) {
this.doChange({action: "remove", osisRef: this.osisRef});
- this.doBack();
} else
this.handleError(inError);
}));
diff --git a/source/popup.js b/source/popup.js
index 0255030..2f600b3 100644
--- a/source/popup.js
+++ b/source/popup.js
@@ -66,8 +66,7 @@ enyo.kind({
highlightVerse: function (inSender, inEvent) {
this.hide();
- 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);
+ var obj = (this.hlExists) ? {id: this.hlId, osisRef: this.osisRef, color: inSender.color} : {osisRef: this.osisRef, color: inSender.color};
api.putHighlight(obj, enyo.bind(this, function (inError, inId) {
if(!inError)
this.doHighlight({osisRef: this.osisRef});
diff --git a/source/settings.js b/source/settings.js
index bddab2b..1d9700e 100644
--- a/source/settings.js
+++ b/source/settings.js
@@ -55,12 +55,16 @@ enyo.kind({
]}
],
+ changed: false,
+
rendered: function () {
this.inherited(arguments);
this.$.container.resized();
},
handleBack: function() {
+ if (this.changed)
+ this.doChange();
this.doBack();
},
@@ -89,8 +93,10 @@ enyo.kind({
handleSettings: function (inSender, inEvent) {
api.putSetting(inSender.key, inSender.getValue(), enyo.bind(this, function (inError, inId) {
if(!inError)
- this.doChange({setting: inSender.key, value: inSender.getValue()});
+ this.changed = true;
+ //this.doChange({setting: inSender.key, value: inSender.getValue()});
}));
+ return true;
},
deleteModules: function () {