aboutsummaryrefslogtreecommitdiffstats
path: root/source/bcSelector.js
diff options
context:
space:
mode:
authorzefanja <zefanja@freenet.de>2013-07-17 20:39:35 +0200
committerzefanja <zefanja@freenet.de>2013-07-17 20:39:35 +0200
commit5b6e0a037365730f161aaebda451671bca4363cf (patch)
tree5905fe49279b168576f0d64822a66399703c290a /source/bcSelector.js
parentf544c16ffca8008d9bae5a464cae4f38017aa9e8 (diff)
downloadbiblez-ng-5b6e0a037365730f161aaebda451671bca4363cf.tar.gz
* added Book and Chapter selector
Diffstat (limited to 'source/bcSelector.js')
-rw-r--r--source/bcSelector.js72
1 files changed, 72 insertions, 0 deletions
diff --git a/source/bcSelector.js b/source/bcSelector.js
new file mode 100644
index 0000000..d2da696
--- /dev/null
+++ b/source/bcSelector.js
@@ -0,0 +1,72 @@
+enyo.kind({
+ name: "biblez.bcSelector",
+ kind: "enyo.FittableRows",
+ events: {
+ onSelect: "",
+ onBack: ""
+ },
+ published: {
+ module: null
+ },
+ components: [
+ {name: "bcPanel", kind: "Panels", arrangerKind: "CardArranger", fit: true, components: [
+ {name: "bookPanel", kind: "enyo.FittableRows", components: [
+ {kind: "onyx.Toolbar", components: [
+ {kind: "onyx.IconButton", src: "assets/back.png", ontap: "doBack"},
+ {content: $L("Books")}
+ ]},
+ {kind: "enyo.Scroller", fit: true, touch: true, components: [
+ {name: "bookRepeater", kind: "Repeater", count: 0, onSetupItem: "setBookItems", components: [
+ {name: "bookItem", classes: "bc-item", ontap: "handleBook"}
+ ]}
+ ]}
+ ]},
+ {name: "chapterPanel", kind: "enyo.FittableRows", components: [
+ {kind: "onyx.Toolbar", components: [
+ {kind: "onyx.IconButton", src: "assets/back.png", ontap: "handleBack"},
+ {content: $L("Chapters")}
+ ]},
+ {kind: "enyo.Scroller", fit: true, touch: true, components: [
+ {name: "chapterRepeater", kind: "Repeater", count: 0, onSetupItem: "setChapterItems", components: [
+ {name: "chapterItem", classes: "bc-item", ontap: "handleChapter"}
+ ]}
+ ]}
+ ]}
+ ]}
+
+ ],
+
+ books: [],
+ currentBook: null,
+
+ setPanel: function (index) {
+ this.$.bcPanel.setIndex(index);
+ },
+
+ handleBack: function (inSender, inEvent) {
+ this.$.bcPanel.setIndex(0)
+ },
+
+ moduleChanged: function (inSender, inEvent) {
+ this.books = this.module.getAllBooks();
+ this.$.bookRepeater.setCount(this.books.length);
+ },
+
+ setBookItems: function (inSender, inEvent) {
+ inEvent.item.$.bookItem.setContent(this.books[inEvent.index].abbrev.slice(0,4));
+ },
+
+ handleBook: function (inSender, inEvent) {
+ this.currentBook = this.books[inEvent.index];
+ this.$.chapterRepeater.setCount(this.currentBook.maxChapter);
+ this.$.bcPanel.setIndex(1);
+ },
+
+ setChapterItems: function (inSender, inEvent) {
+ inEvent.item.$.chapterItem.setContent(inEvent.index+1);
+ },
+
+ handleChapter: function (inSender, inEvent) {
+ this.doSelect({book: this.currentBook, chapter: inEvent.index+1, osis: this.currentBook.abbrev + "." + (inEvent.index+1)});
+ }
+}); \ No newline at end of file