aboutsummaryrefslogtreecommitdiffstats
path: root/source/main.js
diff options
context:
space:
mode:
Diffstat (limited to 'source/main.js')
-rw-r--r--source/main.js46
1 files changed, 33 insertions, 13 deletions
diff --git a/source/main.js b/source/main.js
index 3f239fb..14806cb 100644
--- a/source/main.js
+++ b/source/main.js
@@ -8,40 +8,58 @@ enyo.kind({
components:[
//{kind: "Signals", onSwordReady: "getBible"},
{kind: "onyx.MoreToolbar", components: [
- {content: "", name: "bible"},
+ {kind: "onyx.MenuDecorator", onSelect: "moduleSelected", components: [
+ {content: "", name: "moduleLabel"},
+ {kind: "onyx.Menu", name: "moduleMenu"}
+ ]},
{kind: "onyx.InputDecorator", components: [
- {kind: "onyx.Input", placeholder: "Enter a passage...", onchange: "handlePassage"}
+ {kind: "onyx.Input", placeholder: "Enter a passage...", onchange: "handlePassage", name: "passageInput", value: "Matt 1"}
]}
]},
- {kind: "enyo.Scroller", fit: true, components: [
+ {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/modules.png", ontap: "doOpenModuleManager"}
- //{kind: "onyx.Button", content: "Delete all Modules", ontap: "clearDB"},
+ {kind: "onyx.IconButton", src: "assets/modules.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"}
]}
],
- bible: null,
+ currentModule: null,
+ modules: [],
create: function () {
this.inherited(arguments);
this.$.spinner.stop();
- this.getBible();
+ this.getInstalledModules();
},
- getBible: function (inSender, inEvent) {
+ getInstalledModules: function (inSender, inEvent) {
sword.moduleMgr.getModules(enyo.bind(this, function(inError, inModules) {
if(inModules.length !== 0) {
- this.bible = inModules[0];
- this.$.bible.setContent(this.bible.config.moduleKey);
+ this.currentModule = inModules[0];
+ this.handlePassage();
+ this.$.moduleLabel.setContent(this.currentModule.config.moduleKey);
+ this.modules = inModules;
+ var mods = [];
+ this.modules.forEach(enyo.bind(this, function (mod, idx) {
+ mods.push({content: mod.config.moduleKey, index: idx});
+ }));
+ this.$.moduleMenu.createComponents(mods, {owner: this.$.moduleMenu});
+ this.$.moduleMenu.render();
}
}));
},
+ moduleSelected: function (inSender, inEvent) {
+ this.currentModule = this.modules[inEvent.originator.index];
+ this.$.moduleLabel.setContent(this.currentModule.config.moduleKey);
+ this.handlePassage();
+ },
+
handleInstallTap: function (inSender, inEvent) {
this.$.spinner.start();
self = this;
@@ -54,11 +72,11 @@ enyo.kind({
if(!inError)
sword.moduleMgr.getModule(inId, function (inError, inModule) {
//console.log(inError, inModule);
- self.bible = inModule;
+ self.currentModule = inModule;
self.$.spinner.stop();
if(!inError) {
self.$.main.setContent(enyo.json.stringify(inModule.config));
- self.$.bible.setContent(inModule.config.moduleKey);
+ self.$.moduleLabel.setContent(inModule.config.moduleKey);
}
});
});
@@ -70,7 +88,9 @@ enyo.kind({
handlePassage: function (inSender, inEvent) {
//console.log("PASSAGE", inSender.getValue());
- this.bible.renderText(inSender.getValue(), {oneVersePerLine: true}, enyo.bind(this, function (inError, inText) {
+ if(!inSender)
+ inSender = this.$.passageInput;
+ this.currentModule.renderText(inSender.getValue(), {oneVersePerLine: true}, enyo.bind(this, function (inError, inText) {
//console.log(inError, inText);
this.$.main.setContent(inText);
}));