aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--assets/checkmark.pngbin0 -> 1412 bytes
-rw-r--r--source/App.js2
-rw-r--r--source/main.js205
-rw-r--r--source/moduleManager.js12
4 files changed, 127 insertions, 92 deletions
diff --git a/assets/checkmark.png b/assets/checkmark.png
new file mode 100644
index 0000000..cbec8d6
--- /dev/null
+++ b/assets/checkmark.png
Binary files differ
diff --git a/source/App.js b/source/App.js
index 9090f99..b5a7ff0 100644
--- a/source/App.js
+++ b/source/App.js
@@ -1,5 +1,5 @@
enyo.kind({
- name: "App",
+ name: "App",
kind: enyo.FittableRows,
fit: true,
components: [
diff --git a/source/main.js b/source/main.js
index 4f25dcb..55462eb 100644
--- a/source/main.js
+++ b/source/main.js
@@ -1,132 +1,155 @@
enyo.kind({
- name: "biblez.main",
- kind: "FittableRows",
- fit: true,
- events: {
- onOpenModuleManager: "",
- onModuleChanged: "",
+ name: "biblez.main",
+ kind: "FittableRows",
+ fit: true,
+ events: {
+ onOpenModuleManager: "",
+ onModuleChanged: "",
onOpenBC: ""
- },
- published: {
+ },
+ published: {
passage: ""
- },
- components:[
- //{kind: "Signals", onSwordReady: "getBible"},
+ },
+ components:[
+ //{kind: "Signals", onSwordReady: "getBible"},
{name: "messagePopup", kind: "onyx.Popup", centered: true, floating: true, classes: "message-popup"},
- {kind: "onyx.MoreToolbar", components: [
- {kind: "onyx.MenuDecorator", onSelect: "moduleSelected", components: [
- {kind: "onyx.IconButton", src: "assets/modules.png"},
- {kind: "onyx.Menu", name: "moduleMenu"}
- ]},
+ {kind: "onyx.MoreToolbar", components: [
+ {kind: "onyx.MenuDecorator", onSelect: "moduleSelected", components: [
+ {kind: "onyx.IconButton", src: "assets/modules.png"},
+ {kind: "onyx.Menu", name: "moduleMenu"}
+ ]},
{kind: "onyx.Button", name: "btnPassage", ontap: "doOpenBC"}
- /*{kind: "onyx.InputDecorator", components: [
- {kind: "onyx.Input", placeholder: "Enter a passage...", onchange: "handlePassage", name: "passageInput", value: "Matt 1"}
- ]}*/
- ]},
- {kind: "enyo.Scroller", touch: true, fit: true, components: [
- {kind: "onyx.Spinner", name: "spinner", classes: "onyx-light"},
- {name: "main", classes: "nice-padding", allowHtml: true}
- ]},
- {kind: "onyx.MoreToolbar", components: [
- {kind: "onyx.IconButton", src: "assets/add.png", ontap: "doOpenModuleManager"},
- {kind: "onyx.Button", content: "Delete all Modules", ontap: "clearDB"}
- //{kind: "onyx.Button", content: "Install ESV", esv: true, ontap: "handleInstallTap"},
- //{kind: "Input", type: "file", onchange: "handleInstallTap"}
- ]}
- ],
+ /*{kind: "onyx.InputDecorator", components: [
+ {kind: "onyx.Input", placeholder: "Enter a passage...", onchange: "handlePassage", name: "passageInput", value: "Matt 1"}
+ ]}*/
+ ]},
+ {kind: "enyo.Scroller", touch: true, fit: true, components: [
+ {kind: "onyx.Spinner", name: "spinner", classes: "onyx-light"},
+ {name: "main", classes: "nice-padding", allowHtml: true}
+ ]},
+ {kind: "onyx.MoreToolbar", components: [
+ {kind: "onyx.IconButton", src: "assets/add.png", ontap: "doOpenModuleManager"},
+ {kind: "onyx.Button", content: "Delete all Modules", ontap: "clearDB"}
+ //{kind: "onyx.Button", content: "Install ESV", esv: true, ontap: "handleInstallTap"},
+ //{kind: "Input", type: "file", onchange: "handleInstallTap"}
+ ]}
+ ],
- currentModule: null,
+ currentModule: null,
currentPassage: "Matt 1",
- modules: [],
+ modules: [],
- create: function () {
- this.inherited(arguments);
- this.$.spinner.stop();
+ create: function () {
+ this.inherited(arguments);
+ this.$.spinner.stop();
this.getInstalledModules();
- },
+ },
rendered: function () {
this.inherited(arguments);
},
- getInstalledModules: function (inSender, inEvent) {
- sword.moduleMgr.getModules(enyo.bind(this, function(inError, inModules) {
+ getInstalledModules: function (inSender, inEvent) {
+ sword.moduleMgr.getModules(enyo.bind(this, function(inError, inModules) {
if (!inError) {
if(inModules.length !== 0) {
- this.currentModule = inModules[0];
- this.doModuleChanged({module: this.currentModule});
- this.handlePassage();
- //this.$.moduleLabel.setContent(this.currentModule.config.moduleKey);
this.modules = inModules;
- var mods = [];
- this.modules.forEach(enyo.bind(this, function (mod, idx) {
- if (this.currentModule.modKey === mod.modKey || idx === 0)
- mods.push({content: mod.config.moduleKey, index: idx, active: true});
- else
- mods.push({content: mod.config.moduleKey, index: idx});
- }));
- this.$.moduleMenu.createComponents(mods, {owner: this.$.moduleMenu});
- this.$.moduleMenu.render();
+ this.renderModuleMenu(this.modules);
+ } else {
+ this.$.main.setContent($L("You have no modules installed. Tap on the '+' to install one!"));
}
} else {
this.handleError(inError);
}
- }));
- },
+ }));
+ },
+
+ renderModuleMenu: function (inModules) {
+ if(!inModules)
+ inModules = this.modules;
+ var lastModule = api.get("lastModule");
+ this.$.moduleMenu.destroyClientControls();
+ var mods = [];
+ this.modules.forEach(enyo.bind(this, function (mod, idx) {
+ if ((lastModule && lastModule === mod.modKey)) {
+ //mods.push({content: mod.config.moduleKey, index: idx, active: true, style: "background-color: lightblue"});
+ mods.push({active: true, components: [
+ {content: mod.config.moduleKey, index: idx},
+ {kind: "onyx.IconButton", src: "assets/checkmark.png", style: "float: right;"}
+ ]});
+ this.currentModule = mod;
+ } else
+ mods.push({content: mod.config.moduleKey, index: idx});
+ }));
+ if(this.currentModule === null) {
+ this.currentModule = this.modules[0];
+ mods[0]["active"] = true;
+ }
+ this.$.moduleMenu.createComponents(mods, {owner: this.$.moduleMenu});
+ this.$.moduleMenu.render();
- moduleSelected: function (inSender, inEvent) {
- this.currentModule = this.modules[inEvent.originator.index];
- this.doModuleChanged({module: this.currentModule});
- this.handlePassage();
- },
+ this.doModuleChanged({module: this.currentModule});
+ this.handlePassage();
+ },
- handleInstallTap: function (inSender, inEvent) {
- this.$.spinner.start();
- self = this;
- self.$.main.setContent("Installing Module...");
- var blob = "ESV.zip";
- if (!inSender.esv)
- blob = inEvent.target.files[0];
- sword.installMgr.installModule(blob, function (inError, inId) {
- //console.log(inError, inId);
- if(!inError)
- sword.moduleMgr.getModule(inId, function (inError, inModule) {
- //console.log(inError, inModule);
- self.currentModule = inModule;
- self.$.spinner.stop();
- if(!inError) {
- self.$.main.setContent(enyo.json.stringify(inModule.config));
- self.$.moduleLabel.setContent(inModule.config.moduleKey);
- } else
+ moduleSelected: function (inSender, inEvent) {
+ //console.log(inEvent.originator.index);
+ if (!isNaN(inEvent.originator.index)) {
+ this.currentModule = this.modules[inEvent.originator.index];
+ api.set("lastModule", this.currentModule.modKey);
+ this.renderModuleMenu();
+ //this.doModuleChanged({module: this.currentModule});
+ //this.handlePassage();
+ }
+ },
+
+ handleInstallTap: function (inSender, inEvent) {
+ this.$.spinner.start();
+ self = this;
+ self.$.main.setContent("Installing Module...");
+ var blob = "ESV.zip";
+ if (!inSender.esv)
+ blob = inEvent.target.files[0];
+ sword.installMgr.installModule(blob, function (inError, inId) {
+ //console.log(inError, inId);
+ if(!inError)
+ sword.moduleMgr.getModule(inId, function (inError, inModule) {
+ //console.log(inError, inModule);
+ self.currentModule = inModule;
+ self.$.spinner.stop();
+ if(!inError) {
+ self.$.main.setContent(enyo.json.stringify(inModule.config));
+ self.$.moduleLabel.setContent(inModule.config.moduleKey);
+ } else
this.handleError(inError);
- });
+ });
else
this.handleError(inError);
- });
- },
+ });
+ },
- clearDB: function () {
- sword.dataMgr.clearDatabase();
- },
+ clearDB: function () {
+ sword.dataMgr.clearDatabase();
+ },
passageChanged: function (inSender, inEvent) {
this.currentPassage = inEvent.book.abbrev + " " + inEvent.chapter;
this.handlePassage(inEvent.osis);
},
- handlePassage: function (passage) {
- //console.log("PASSAGE", inSender.getValue());
- if(!passage)
- passage = this.currentPassage;
+ handlePassage: function (passage) {
+ //console.log("PASSAGE", inSender.getValue());
+ if(!passage)
+ passage = this.currentPassage;
this.$.btnPassage.setContent(this.currentPassage);
- this.currentModule.renderText(passage, {oneVersePerLine: true}, enyo.bind(this, function (inError, inText) {
- console.log(inError);
+ this.currentModule.renderText(passage, {oneVersePerLine: true}, enyo.bind(this, function (inError, inText) {
+ console.log(inError);
if(!inError)
this.$.main.setContent(inText);
else
this.handleError(inError);
- }));
- },
+ }));
+ },
handleError: function (inMessage) {
this.$.messagePopup.setContent(inMessage);
diff --git a/source/moduleManager.js b/source/moduleManager.js
index 13f7646..3ca8b4f 100644
--- a/source/moduleManager.js
+++ b/source/moduleManager.js
@@ -7,6 +7,7 @@ enyo.kind({
onInstalled: ""
},
components: [
+ {name: "messagePopup", kind: "onyx.Popup", centered: true, floating: true, classes: "message-popup"},
{name: "scrim", kind: "onyx.Scrim", classes: "onyx-scrim-translucent"},
{kind: "onyx.MoreToolbar", components: [
{kind: "onyx.IconButton", src: "assets/back.png", ontap: "handleBack"},
@@ -99,6 +100,8 @@ enyo.kind({
api.set("repos", inRepos);
api.set("lastRepoUpdate", {time: new Date().getTime()});
this.setupRepoPicker(inRepos);
+ } else {
+ this.handleError((inError.message) ? inError.message : inError);
}
}));
},
@@ -142,6 +145,8 @@ enyo.kind({
//this.$.langList.setCount(inModules.length);
this.prepareLangList(this.modules);
+ } else {
+ this.handleError((inError.message) ? inError.message : inError);
}
}));
}
@@ -207,6 +212,8 @@ enyo.kind({
sword.installMgr.installModule(this.currentModule.url, enyo.bind(this, function (inError, inModule) {
if (!inError) {
this.doInstalled();
+ } else {
+ this.handleError((inError.message) ? inError.message : inError);
}
//console.log(inError, inModule);
this.$.progressBar.hide();
@@ -216,5 +223,10 @@ enyo.kind({
enyo.bind(this, function (inEvent) {
this.$.progressBar.animateProgressTo(inEvent.loaded/inEvent.total*100);
}));
+ },
+
+ handleError: function (inMessage) {
+ this.$.messagePopup.setContent(inMessage);
+ this.$.messagePopup.show();
}
}); \ No newline at end of file