aboutsummaryrefslogtreecommitdiffstats
path: root/source/dataView.js
diff options
context:
space:
mode:
Diffstat (limited to 'source/dataView.js')
-rw-r--r--source/dataView.js48
1 files changed, 42 insertions, 6 deletions
diff --git a/source/dataView.js b/source/dataView.js
index e102995..e64bd43 100644
--- a/source/dataView.js
+++ b/source/dataView.js
@@ -11,7 +11,7 @@ enyo.kind({
},
components: [
{name: "messagePopup", kind: "onyx.Popup", centered: true, floating: true, classes: "message-popup"},
- {kind: "onyx.MoreToolbar", layoutKind:"FittableColumnsLayout", components: [
+ {kind: "onyx.MoreToolbar", layoutKind:"FittableColumnsLayout", classes: "main-toolbar", components: [
{name: "btBack", kind: "onyx.IconButton", src: "assets/back.png", ontap: "handleBack"},
{name: "btHide", kind: "onyx.IconButton", src: "assets/hide.png", showing: false, ontap: "handleBack"},
{kind: "onyx.RadioGroup", onActivate:"sectionActivated", classes: "center", fit: true, defaultKind: "onyx.IconButton", components: [
@@ -21,7 +21,14 @@ enyo.kind({
]},
]},
{name: "noData", classes: "center", style: "margin-top: 10px;", showing: false},
- {name: "dataList", kind: "List", fit: true, touch: true, onSetupItem: "setupItem", components: [
+ {name: "dataList", kind: "AroundList", fit: true, onSetupItem: "setupItem", aboveComponents: [
+ {kind: "onyx.Toolbar", layoutKind: "FittableColumnsLayout", components: [
+ {kind: "onyx.InputDecorator", fit: true, noStretch: true, layoutKind: "FittableColumnsLayout", components: [
+ {kind: "onyx.Input", placeholder: $L("Search..."), fit: true, oninput: "searchInputChange"},
+ {kind: "Image", src: "assets/search-input.png", style: "height: 20px; width: 20px;"}
+ ]}
+ ]},
+ ], components: [
{name: "item", classes: "item", ontap: "handleListTap", components: [
//{kind: "enyo.FittableRows", components: [
{name: "itemOsis", classes: ""},
@@ -32,6 +39,7 @@ enyo.kind({
],
data: [],
+ filtered: [],
showHideButton: function () {
this.$.btHide.show();
@@ -52,6 +60,7 @@ enyo.kind({
},
sectionChanged: function (inSender, inEvent) {
+ this.filter = null;
if (this.section === "bookmarks") {
this.$.rbBm.setActive(true);
api.getAllBookmarks(enyo.bind(this, function (inError, inData) {
@@ -67,7 +76,6 @@ enyo.kind({
if(!inError) {
this.data = inData;
this.updateList();
- this.$.dataList.refresh();
} else
this.handleError(inError);
}));
@@ -86,6 +94,7 @@ enyo.kind({
updateList: function () {
this.$.dataList.setCount(this.data.length);
if(this.data.length === 0) {
+ this.$.dataList.hide();
this.$.noData.show();
if(this.section === "bookmarks")
this.$.noData.setContent($L("No Bookmarks.") + " " + $L("Tap on a verse number to add one."));
@@ -93,14 +102,17 @@ enyo.kind({
this.$.noData.setContent($L("No Notes.") + " " + $L("Tap on a verse number to add one."));
else if(this.section === "highlights")
this.$.noData.setContent($L("No Highlights.") + " " + $L("Tap on a verse number to add one."));
- } else
+ } else {
this.$.noData.hide();
- this.$.dataList.refresh();
+ this.$.dataList.show();
+ }
+ this.$.dataList.reset();
this.$.dataList.reflow();
+ this.$.dataList.scrollToRow(0);
},
setupItem: function(inSender, inEvent) {
- var data = this.data[inEvent.index];
+ var data = this.filter ? this.filtered[inEvent.index] : this.data[inEvent.index];
this.$.itemOsis.setContent(api.formatOsis(data.osisRef));
if(this.section === "highlights") {
this.$.item.applyStyle("background-color", data.color);
@@ -121,6 +133,30 @@ enyo.kind({
this.doVerse({osisRef: this.data[inEvent.index].osisRef});
},
+ searchInputChange: function(inSender) {
+ enyo.job(this.id + ":search", this.bindSafely("filterList", inSender.getValue()), 200);
+ return true;
+ },
+
+ filterList: function(inFilter) {
+ if (inFilter != this.filter) {
+ this.filter = inFilter;
+ this.filtered = this.generateFilteredData(inFilter);
+ this.$.dataList.setCount(this.filtered.length);
+ this.$.dataList.reset();
+ }
+ },
+ generateFilteredData: function(inFilter) {
+ var re = new RegExp(inFilter, "i");
+ var r = [];
+ for (var i=0, d; (d=this.data[i]); i++) {
+ if (d.osisRef.match(re) || api.formatOsis(d.osisRef).match(re) || (d.text && d.text.match(re))) {
+ r.push(d);
+ }
+ }
+ return r;
+ },
+
handleBack: function() {
this.doBack();
},