diff options
-rw-r--r-- | source/App.js | 17 | ||||
-rw-r--r-- | source/main.js | 46 | ||||
-rw-r--r-- | source/moduleManager.js | 48 |
3 files changed, 84 insertions, 27 deletions
diff --git a/source/App.js b/source/App.js index 9b2a18b..3bd63fb 100644 --- a/source/App.js +++ b/source/App.js @@ -3,22 +3,33 @@ enyo.kind({ kind: enyo.FittableRows, fit: true, components: [ - {name: "panel", kind: "Panels", fit: true, classes: "app-panels", arrangerKind: "CardArranger", draggable: false, components: [ + {name: "panel", kind: "Panels", fit: true, classes: "app-panels", arrangerKind: "CardArranger", draggable: false, onTransitionFinish: "handlePanels", components: [ {name: "main", kind: "biblez.main", onOpenModuleManager: "openModuleManager"}, - {name: "moduleManager", kind: "biblez.moduleManager", onBack: "handleBack"} + {name: "moduleManager", kind: "biblez.moduleManager", onBack: "handleBack", onInstalled: "handleInstalledModule"} //{name: "settings"} ]} ], rendered: function () { this.inherited(arguments); - this.$.panel.setIndex(1); + //this.$.panel.setIndex(0); + }, + + handlePanels: function (inSender, inEvent) { + if(inEvent.toIndex === 1) { + this.$.moduleManager.start(); + } + }, handleBack: function (inSender, inEvent) { this.$.panel.setIndex(0); }, + handleInstalledModule: function (inSender, inEvent) { + this.$.main.getInstalledModules(); + }, + openModuleManager: function (inSender, inEvent) { this.$.panel.setIndex(1); } 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); })); diff --git a/source/moduleManager.js b/source/moduleManager.js index 5363cf3..eb0f0fc 100644 --- a/source/moduleManager.js +++ b/source/moduleManager.js @@ -3,9 +3,11 @@ enyo.kind({ kind: "enyo.FittableRows", fit: true, events: { - onBack: "" + onBack: "", + onInstalled: "" }, components: [ + {name: "scrim", kind: "onyx.Scrim", classes: "onyx-scrim-translucent"}, {kind: "onyx.MoreToolbar", components: [ {kind: "onyx.Button", content: $L("Back"), ontap: "handleBack"}, {content: $L("Module Manager")} @@ -33,21 +35,24 @@ enyo.kind({ {kind: enyo.Scroller, touch: true, fit: true, components: [ {name: "detailsContainer", showing: false, classes: "content-container", components: [ {name: "detailsName", classes: "title"}, - {kind: "onyx.Button", ontap: "installModule", name: "btnInstall", content: $L("Install Module"), classes: "onyx-affirmative", style: "margin-left: 10px;"}, + //{kind: "onyx.ProgressBar", name: "progressBar", progress: 0, showing: false, showStripes: false}, + {kind: "onyx.Button", ontap: "installModule", name: "btnInstall", classes: "onyx-affirmative", content: $L("Install Module"), style: "margin-left: 10px;"}, {name: "detailsDescription", allowHtml: true, classes: "nice-padding"} ]} ]} ]} ]}, - {kind: "onyx.MoreToolbar", components: [ + {kind: "onyx.MoreToolbar", name: "bottomTB", components: [ {kind: "onyx.PickerDecorator", components: [ {}, {name: "repoPicker", kind: "onyx.Picker", onSelect: "handleRepoChange"} - ]} - ]}, + ]}, + {kind: "onyx.ProgressBar", name: "progressBar", progress: 0, showing: false, showStripes: false, fit: true} + ]} ], lang: [], + started: false, repos: [], modules: [], langModules: [], @@ -55,10 +60,18 @@ enyo.kind({ rendered: function () { this.inherited(arguments); - if (!api.get("lastRepoUpdate")) - this.getRepos(); - else - this.setupRepoPicker(); + + }, + + start: function () { + if (!this.started) { + this.$.scrim.show(); + if (!api.get("lastRepoUpdate")) + this.getRepos(); + else + this.setupRepoPicker(); + } + this.started = true; }, handleBack: function() { @@ -72,6 +85,10 @@ enyo.kind({ handleRepoChange: function (inSender, inEvent) { this.$.detailsContainer.hide(); + this.$.scrim.show(); + this.$.modList.setCount(0); + this.$.modList.refresh(); + this.$.panel.setIndex(0); api.set("currentRepo", this.repos[inEvent.selected.index]); this.getRemoteModules(this.repos[inEvent.selected.index]); }, @@ -140,6 +157,7 @@ enyo.kind({ })); this.$.langList.setCount(this.lang.length); this.$.langList.refresh(); + this.$.scrim.hide(); }, setupLangItem: function(inSender, inEvent) { @@ -181,10 +199,18 @@ enyo.kind({ installModule: function (inSender, inEvent) { console.log(this.currentModule.url); - this.$.btnInstall.setContent($L("Installing...")); + this.$.btnInstall.setDisabled(true); + this.$.progressBar.show(); + this.$.bottomTB.render(); sword.installMgr.installModule(this.currentModule.url, enyo.bind(this, function (inError, inModule) { + this.doInstalled(); console.log(inError, inModule); - this.$.btnInstall.setContent($L("Installed Module")); + this.$.progressBar.hide(); + this.$.progressBar.setProgress(0); + this.$.btnInstall.setDisabled(false); + }), + enyo.bind(this, function (inEvent) { + this.$.progressBar.animateProgressTo(inEvent.loaded/inEvent.total*100); })); } });
\ No newline at end of file |