aboutsummaryrefslogtreecommitdiffstats
path: root/source/main.js
diff options
context:
space:
mode:
authorzefanja <zefanja@freenet.de>2013-07-15 16:54:56 +0200
committerzefanja <zefanja@freenet.de>2013-07-15 16:54:56 +0200
commit1ee45c70e15c84f354dd97b600f2d1777f48abad (patch)
tree0d0da9a13af38fb972f1febb8e627d98dcbdfa2c /source/main.js
parent5dcfe1aaed10ab6da4cb606a5df81e7cbf2ee258 (diff)
downloadbiblez-ng-1ee45c70e15c84f354dd97b600f2d1777f48abad.tar.gz
* added basic module handling
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);
}));