diff options
author | zefanja <zefanja@freenet.de> | 2014-02-09 20:10:25 +0700 |
---|---|---|
committer | zefanja <zefanja@freenet.de> | 2014-02-09 20:10:25 +0700 |
commit | 4bebba6d4657308be57c27bf4f288000f9487da0 (patch) | |
tree | d4ab58540f9ad9b0ea4f51d2df07b43f6a2eb37f /source | |
parent | fbe606637450b229668a3c2473e4cec214b6e310 (diff) | |
download | biblez-ng-4bebba6d4657308be57c27bf4f288000f9487da0.tar.gz |
* improved desktop's module manager (added option to remove modules)
Diffstat (limited to 'source')
-rw-r--r-- | source/main.js | 7 | ||||
-rw-r--r-- | source/moduleManagerDesktop.js | 63 |
2 files changed, 60 insertions, 10 deletions
diff --git a/source/main.js b/source/main.js index 1f140a1..aa166cf 100644 --- a/source/main.js +++ b/source/main.js @@ -288,8 +288,13 @@ enyo.kind({ } this.handleUserData(this.currentPassage.osis); this.renderHistory(); - } else + } else { + if(inError.code && inError.code === 123) { + //handle old internal module format + } this.handleError(inError.message); + } + }) ); }, diff --git a/source/moduleManagerDesktop.js b/source/moduleManagerDesktop.js index 0bd63c0..c2ee1bd 100644 --- a/source/moduleManagerDesktop.js +++ b/source/moduleManagerDesktop.js @@ -14,7 +14,7 @@ enyo.kind({ {content: $L("Module Manager")} //{kind: "onyx.IconButton", src: "assets/delete.png", ontap: "clearDB"} ]}, - {classes: "center", components: [ + {kind: "enyo.Scroller", fit: true, classes: "center settings-container", components: [ {content: $L("Download a zipped module from one of the following repositories:")}, {allowHtml: true, content: "<ul><li><a target='_blank' href='http://www.crosswire.org/sword/modules/ModDisp.jsp?modType=Bibles'>CrossWire Main</a></li>" + "<li><a target='_blank' href='http://www.crosswire.org/sword/modules/ModDisp.jsp?modType=Bibles&av=true'>CrossWire av11n</a></li>" + @@ -23,16 +23,42 @@ enyo.kind({ {content: $L("To install the module, select the module file!")}, {kind: "onyx.Input", type: "file", id: "files", name: "files[]", onchange: "installModule"}, {tag: "br"}, - {kind: "onyx.Spinner", name: "spinner", showing: false, classes: "onyx-light center"} + {kind: "onyx.Spinner", name: "spinner", showing: false, classes: "onyx-light center"}, + {tag: "br"}, + {name: "gbModules", showing: false, kind: "onyx.Groupbox", components: [ + {kind: "onyx.GroupboxHeader", content: $L("Installed Modules")}, + {name: "moduleList", kind: "Repeater", count: 0, onSetupItem: "setupModules", components: [ + {kind: "enyo.FittableColumns", classes: "settings-row item", components: [ + {name: "moduleName", style: "line-height: 35px;", fit: true}, + {name: "btRemove", modKey: null, kind: "onyx.Button", content: "Remove", classes: "onyx-negative", ontap: "handleRemove"} + ]} + ]} + ]} ]} ], - lang: [], - started: false, - repos: [], modules: [], - langModules: [], - currentModule: null, + + rendered: function () { + this.inherited(arguments); + this.getModules(); + }, + + getModules: function () { + sword.moduleMgr.getModules(enyo.bind(this, function(inError, inModules) { + if (!inError) { + if(inModules.length !== 0) { + this.$.gbModules.show(); + } else if (inModules.length === 0) { + this.$.gbModules.hide(); + } + this.modules = inModules; + this.$.moduleList.setCount(this.modules.length); + } else { + this.handleError(inError); + } + })); + }, handleBack: function() { this.doBack(); @@ -43,6 +69,7 @@ enyo.kind({ sword.installMgr.installModule(inEvent.target.files[0], enyo.bind(this, function (inError, inModule) { if (!inError) { this.doInstalled(); + this.getModules(); this.$.spinner.stop(); this.handleError("Installed Module!"); } else { @@ -51,8 +78,26 @@ enyo.kind({ })); }, - clearDB: function () { - sword.dataMgr.clearDatabase(); + setupModules: function (inSender, inEvent) { + var index = inEvent.index; + var item = inEvent.item; + item.$.moduleName.setContent(this.modules[index].modKey); + item.$.btRemove.modKey = this.modules[index].modKey; + return true; + }, + + handleRemove: function (inSender, inEvent) { + if(inEvent.originator && inEvent.originator.modKey) { + sword.installMgr.removeModule(inEvent.originator.modKey, enyo.bind(this, function (inError) { + if(!inError) { + this.doInstalled(); + this.getModules(); + } else { + this.handleError(inError); + } + })); + } + return true; }, handleError: function (inMessage) { |