aboutsummaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/App.js2
-rw-r--r--source/api.js79
-rw-r--r--source/dataView.js45
-rw-r--r--source/main.js3
-rw-r--r--source/moduleManager.js27
-rw-r--r--source/settings.js2
6 files changed, 89 insertions, 69 deletions
diff --git a/source/App.js b/source/App.js
index 8aa1e2a..9550160 100644
--- a/source/App.js
+++ b/source/App.js
@@ -103,7 +103,7 @@ enyo.kind({
},
openDataView: function (inSender, inEvent) {
- this.$.dataView.setSection(inEvent.section);
+ this.$.dataView.updateSection(inEvent.section);
this.$.panel.setIndex(6);
},
diff --git a/source/api.js b/source/api.js
index fdd9e22..d2efafc 100644
--- a/source/api.js
+++ b/source/api.js
@@ -13,7 +13,7 @@ var api = {
wrapper: function (inCallback) {
//console.log("isInitialized...", this.isInitialized);
if (this.isInitialized) {
- inCallback(null, this.db);
+ if(inCallback) inCallback(null, this.db);
} else {
var self = this;
this.db = new this.store({
@@ -35,7 +35,7 @@ var api = {
bmWrapper: function (inCallback) {
//console.log("isInitialized...", this.isInitialized);
if (this.isBmInitialized) {
- inCallback(null, this.bmStore);
+ if(inCallback) inCallback(null, this.bmStore);
} else {
var self = this;
this.bmStore = new this.store({
@@ -62,7 +62,7 @@ var api = {
hlWrapper: function (inCallback) {
//console.log("isInitialized...", this.isHlInitialized);
if (this.isHlInitialized) {
- inCallback(null, this.hlStore);
+ if(inCallback) inCallback(null, this.hlStore);
} else {
var self = this;
this.hlStore = new this.store({
@@ -88,7 +88,7 @@ var api = {
noteWrapper: function (inCallback) {
//console.log("isInitialized...", this.isHlInitialized);
if (this.isNoteInitialized) {
- inCallback(null, this.noteStore);
+ if(inCallback) inCallback(null, this.noteStore);
} else {
var self = this;
this.noteStore = new this.store({
@@ -127,7 +127,7 @@ var api = {
put: function (inObject, inCallback) {
this.wrapper(enyo.bind(this, function (inError, inDB) {
if(!inError) this._put(inDB, inObject, inCallback);
- else inCallback(inError);
+ else if(inCallback) inCallback(inError);
}));
},
@@ -143,12 +143,12 @@ var api = {
inOsisObject["bookmarkId"] = inId;
this.put(inOsisObject, inCallback);
} else
- inCallback(inError);
+ if(inCallback) inCallback(inError);
}));
else
- inCallback(inError);
+ if(inCallback) inCallback(inError);
}));
- else inCallback(inError);
+ else if(inCallback) inCallback(inError);
}));
},
@@ -164,12 +164,12 @@ var api = {
inOsisObject["highlightId"] = inId;
this.put(inOsisObject, inCallback);
} else
- inCallback(inError);
+ if(inCallback) inCallback(inError);
}));
else
- inCallback(inError);
+ if(inCallback) inCallback(inError);
}));
- else inCallback(inError);
+ else if(inCallback) inCallback(inError);
}));
},
@@ -188,10 +188,10 @@ var api = {
inOsisObject["noteId"] = inId;
this.put(inOsisObject, inCallback);
} else
- inCallback(inError);
+ if(inCallback) inCallback(inError);
}));
else
- inCallback(inError);
+ if(inCallback) inCallback(inError);
}));
} else {
//Update an existing note
@@ -200,11 +200,11 @@ var api = {
inNoteObject["text"] = inObject["text"];
this._put(inDB, inNoteObject, inCallback);
} else {
- inCallback(inError);
+ if(inCallback) inCallback(inError);
}
}));
}
- else inCallback(inError);
+ else if(inCallback) inCallback(inError);
}));
},
@@ -244,70 +244,70 @@ var api = {
_query: function(inDB, inOptions, inCallback) {
//inOptions["onError"] = function (inError) {inCallback(inError);};
inDB.query(function (inResults) {
- inCallback(null, inResults);
+ if(inCallback) inCallback(null, inResults);
}, inOptions);
},
get: function (inId, inCallback) {
this.wrapper(enyo.bind(this, function (inError, inDB) {
if(!inError) this._get(inDB, inId, inCallback);
- else inCallback(inError);
+ else if(inCallback) inCallback(inError);
}));
},
getAll: function(inCallback) {
this.wrapper(enyo.bind(this, function (inError, inDB) {
if(!inError) this._getAll(inDB, inCallback);
- else inCallback(inError);
+ else if(inCallback) inCallback(inError);
}));
},
getBookmark: function (inId, inCallback) {
this.bmWrapper(enyo.bind(this, function (inError, inDB) {
if(!inError) this._get(inDB, inId, inCallback);
- else inCallback(inError);
+ else if(inCallback) inCallback(inError);
}));
},
getAllBookmarks: function (inCallback) {
this.bmWrapper(enyo.bind(this, function (inError, inDB) {
if(!inError) this._query(inDB, {index: "osisRef"}, inCallback);
- else inCallback(inError);
+ else if(inCallback) inCallback(inError);
}));
},
getHighlights: function (inIds, inCallback) {
this.hlWrapper(enyo.bind(this, function (inError, inDB) {
if(!inError) this._getBatch(inDB, inIds, inCallback);
- else inCallback(inError);
+ else if(inCallback) inCallback(inError);
}));
},
getAllHighlights: function (inCallback) {
this.hlWrapper(enyo.bind(this, function (inError, inDB) {
if(!inError) this._query(inDB, {index: "osisRef"}, inCallback);
- else inCallback(inError);
+ else if(inCallback) inCallback(inError);
}));
},
getNote: function (inId, inCallback) {
this.noteWrapper(enyo.bind(this, function (inError, inDB) {
if(!inError) this._get(inDB, inId, inCallback);
- else inCallback(inError);
+ else if(inCallback) inCallback(inError);
}));
},
getNotes: function (inIds, inCallback) {
this.noteWrapper(enyo.bind(this, function (inError, inDB) {
if(!inError) this._getBatch(inDB, inIds, inCallback);
- else inCallback(inError);
+ else if(inCallback) inCallback(inError);
}));
},
getAllNotes: function (inCallback) {
this.noteWrapper(enyo.bind(this, function (inError, inDB) {
if(!inError) this._query(inDB, {index: "osisRef"}, inCallback);
- else inCallback(inError);
+ else if(inCallback) inCallback(inError);
}));
},
@@ -327,7 +327,7 @@ var api = {
if(z === inVMax) inCallback(null, userData);
else z++;
} else
- inCallback(inError);
+ if(inCallback) inCallback(inError);
});
}
},
@@ -354,14 +354,14 @@ var api = {
delete inOsisObject["bookmarkId"];
this.put(inOsisObject, inCallback);
} else
- inCallback({message: "api.removeBookmark: Couldn't remove bookmarkId from osisObject"});
+ if(inCallback) inCallback({message: "api.removeBookmark: Couldn't remove bookmarkId from osisObject"});
} else
- inCallback(inError);
+ if(inCallback) inCallback(inError);
}));
else
- inCallback(inError);
+ if(inCallback) inCallback(inError);
}));
- else inCallback(inError);
+ else if(inCallback) inCallback(inError);
}));
},
@@ -376,14 +376,14 @@ var api = {
delete inOsisObject["highlightId"];
this.put(inOsisObject, inCallback);
} else
- inCallback({message: "api.removeHighlight: Couldn't remove highlightId from osisObject"});
+ if(inCallback) inCallback({message: "api.removeHighlight: Couldn't remove highlightId from osisObject"});
} else
- inCallback(inError);
+ if(inCallback) inCallback(inError);
}));
else
- inCallback(inError);
+ if(inCallback) inCallback(inError);
}));
- else inCallback(inError);
+ else if(inCallback) inCallback(inError);
}));
},
@@ -398,24 +398,25 @@ var api = {
delete inOsisObject["noteId"];
this.put(inOsisObject, inCallback);
} else
- inCallback({message: "api.removeHighlight: Couldn't remove noteId from osisObject"});
+ if(inCallback) inCallback({message: "api.removeHighlight: Couldn't remove noteId from osisObject"});
} else
- inCallback(inError);
+ if(inCallback) inCallback(inError);
}));
else
- inCallback(inError);
+ if(inCallback) inCallback(inError);
}));
- else inCallback(inError);
+ else if(inCallback) inCallback(inError);
}));
},
putSetting: function (inKey, inValue, inCallback) {
this.get("settings", enyo.bind(this, function (inError, inSettings) {
if(!inError) {
+ if(!inSettings) inSettings = {id: "settings"};
inSettings[inKey] = inValue;
this.put(inSettings, inCallback);
} else {
- inCallback(inError);
+ if(inCallback) inCallback(inError);
}
}));
},
diff --git a/source/dataView.js b/source/dataView.js
index c9444a8..e5d3a21 100644
--- a/source/dataView.js
+++ b/source/dataView.js
@@ -39,19 +39,19 @@ enyo.kind({
return true;
},
+ updateSection: function (inSection) {
+ if(inSection)
+ this.section = inSection;
+ 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);
- 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();
+ this.updateList();
} else
this.handleError(inError);
}));
@@ -60,12 +60,7 @@ enyo.kind({
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.updateList();
this.$.dataList.refresh();
} else
this.handleError(inError);
@@ -75,19 +70,29 @@ enyo.kind({
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();
+ this.updateList();
} else
this.handleError(inError);
}));
}
},
+ updateList: function () {
+ this.$.dataList.setCount(this.data.length);
+ if(this.data.length === 0) {
+ this.$.noData.show();
+ if(this.section === "bookmarks")
+ this.$.noData.setContent($L("No Bookmarks.") + " " + $L("Tap on a verse number to add one."));
+ else if(this.section === "note")
+ this.$.noData.setContent($L("No Notes.") + " " + $L("Tap on a verse number to add one."));
+ else if(this.section === "highlights")
+ this.$.noData.setContent($L("No Highlights.") + " " + $L("Tap on a verse number to add one."));
+ } else
+ this.$.noData.hide();
+ this.$.dataList.refresh();
+ this.$.dataList.reflow();
+ },
+
setupItem: function(inSender, inEvent) {
var data = this.data[inEvent.index];
this.$.itemOsis.setContent(api.formatOsis(data.osisRef));
diff --git a/source/main.js b/source/main.js
index 0a3a283..ccb19df 100644
--- a/source/main.js
+++ b/source/main.js
@@ -24,7 +24,7 @@ enyo.kind({
{name: "bcPopup", classes: "biblez-bc-popup", kind: "onyx.Popup", modal: true, floating: true, components: [
{kind: "biblez.bcSelector", name: "bcSelector", onSelect: "passageChanged", onBack: "closePopup"}
]},
- {kind: "onyx.MoreToolbar", classes: "main-toolbar", name: "topTB", components: [
+ {kind: "onyx.MoreToolbar", showing: false, classes: "main-toolbar", name: "topTB", components: [
{name: "moduleSelector", kind: "onyx.MenuDecorator", onSelect: "moduleSelected", components: [
{kind: "onyx.Button", name: "btnModules", classes: "tb-button", style: "background-color: #934A15;"},
{kind: "onyx.Menu", maxHeight: "300", name: "moduleMenu"}
@@ -166,6 +166,7 @@ enyo.kind({
this.$.firstStart.show();
this.$.mainPanel.setIndex(5);
}
+ this.reflow();
} else {
this.handleError(inError);
}
diff --git a/source/moduleManager.js b/source/moduleManager.js
index 332c068..ece7f4b 100644
--- a/source/moduleManager.js
+++ b/source/moduleManager.js
@@ -15,6 +15,7 @@ enyo.kind({
]},
{name: "panel", arrangerKind: "CollapsingArranger", fit: true, kind: "Panels", classes: "app-panels", components: [
{name: "panelLang", kind: "enyo.FittableRows", components: [
+ {classes: "center", components: [{kind: "onyx.Spinner", name: "spinner", classes: "onyx-light center"}]},
{name: "langList", kind: "List", fit: true, touch: true, onSetupItem: "setupLangItem", components: [
{classes: "item", ontap: "handleLanguage", components: [
{kind: "enyo.FittableColumns", components: [
@@ -61,7 +62,8 @@ enyo.kind({
start: function () {
if (!this.started) {
- this.$.scrim.show();
+ //this.$.scrim.show();
+ this.$.spinner.show();
api.get("repos", enyo.bind(this, function (inError, inData) {
if(!inData)
this.getRepos();
@@ -83,10 +85,14 @@ enyo.kind({
handleRepoChange: function (inSender, inEvent) {
this.$.detailsContainer.hide();
- this.$.scrim.show();
+
this.$.modList.setCount(0);
this.$.modList.refresh();
+ this.$.langList.setCount(0);
+ this.$.langList.refresh();
+ this.$.spinner.show();
this.$.panel.setIndex(0);
+
api.get("repos", enyo.bind(this, function(inError, inRepos) {
if(!inError) {
inRepos["currentRepo"] = this.repos[inEvent.selected.index];
@@ -94,6 +100,7 @@ enyo.kind({
} else
this.handleError(inError);
}));
+ //console.log(inEvent.selected.index);
this.getRemoteModules(this.repos[inEvent.selected.index]);
},
@@ -137,16 +144,19 @@ enyo.kind({
getRemoteModules: function (inRepo) {
//console.log(inRepo);
- api.get("currentModules", enyo.bind(this, function (inError, currentModules) {
+ api.get("downloadedModules", enyo.bind(this, function (inError, allModules) {
+ //console.log(inRepo, allModules, this.repos);
if(!inError) {
- if(currentModules && inRepo.name === currentModules.name) {
- this.modules = currentModules.modules;
+ if(allModules && allModules.hasOwnProperty(inRepo.name.replace(" ", ""))) {
+ this.modules = allModules[inRepo.name.replace(" ", "")].modules;
this.prepareLangList(this.modules);
} else {
sword.installMgr.getModules(inRepo, enyo.bind(this, function (inError, inModules) {
//enyo.log(inError, inModules, inModules.length);
if(!inError) {
- api.put({id: "currentModules", modules: inModules, name: inRepo.name}, enyo.bind(this, function (inError, inId) {
+ if(!allModules) allModules = {id: "downloadedModules"};
+ allModules[inRepo.name.replace(" ", "")] = {modules: inModules, name: inRepo.name};
+ api.put(allModules, enyo.bind(this, function (inError, inId) {
if(inError)
this.handleError(inError);
}));
@@ -165,6 +175,7 @@ enyo.kind({
},
prepareLangList: function (inModules) {
+ this.$.spinner.hide();
this.lang = [];
inModules.forEach(enyo.bind(this, function(module, idx) {
//console.log(module.Lang, inModules[idx+1].Lang);
@@ -174,9 +185,11 @@ enyo.kind({
this.lang.push({lang: module.Lang});
}
}));
+ this.$.panelLang.reflow();
this.$.langList.setCount(this.lang.length);
this.$.langList.refresh();
- this.$.scrim.hide();
+
+
},
setupLangItem: function(inSender, inEvent) {
diff --git a/source/settings.js b/source/settings.js
index e7673b1..f5fa5de 100644
--- a/source/settings.js
+++ b/source/settings.js
@@ -53,7 +53,7 @@ enyo.kind({
toggleLinebreak: function (inSender, inEvent) {
api.putSetting("linebreak", inSender.getValue(), enyo.bind(this, function (inError, inId) {
if(!inError)
- this.doChange({setting: "linebreak", value: true});
+ this.doChange({setting: "linebreak", value: inSender.getValue()});
}));
},