X-Git-Url: http://git.bytex64.net/?a=blobdiff_plain;f=www%2Fjssrc%2Fblerg%2FPager.js;h=f311d1f60a7a4e92a947ee2699766d3638ec63cd;hb=HEAD;hp=9ae703b07d56c17c2950331c6b0d333d8ddba094;hpb=9818631aecddd827374a0c01b3ec287e7b018bb1;p=blerg.git diff --git a/www/jssrc/blerg/Pager.js b/www/jssrc/blerg/Pager.js index 9ae703b..f311d1f 100644 --- a/www/jssrc/blerg/Pager.js +++ b/www/jssrc/blerg/Pager.js @@ -1,36 +1,49 @@ enyo.kind({ - name: "blerg.Pager", - kind: "Control", - listKind: "Control", - lastRecord: null, - components: [ - {name: "records"}, - {name: "loadMoreButton", kind: "onyx.Button", onclick: "loadMore", content: "Load More"} - ], - addItems: function(items) { - this.$.records.createComponents(items, {kind: this.listKind}); - for (var i = 0; i < items.length; i++) { - var r = parseInt(items[i].record); - if (r < this.lastRecord || this.lastRecord == null) - this.lastRecord = r; - } - this.$.records.render(); - if (this.lastRecord == 0) - this.$.loadMoreButton.hide(); - }, - loadMore: function() { - if (this.lastRecord == 0) - return; + name: "blerg.Pager", + kind: "Control", + listKind: "Control", + lastRecord: null, + components: [ + {name: "records"}, + {name: "spinner", kind: "OldSchoolSpinner", showing: false} + ], + addItems: function(items) { + if (items.length > 0) { + this.$.records.createComponents(items, {kind: this.listKind}); + for (var i = 0; i < items.length; i++) { + var r = parseInt(items[i].record); + if (r < this.lastRecord || this.lastRecord == null) + this.lastRecord = r; + } + } else { + this.$.records.createComponent({content: "No items"}); + } + this.$.records.render(); + this.stopLoadAnimation(); + }, + loadMore: function() { + if (this.lastRecord == 0) + return; - if (this.lastRecord != null) { - var to = this.lastRecord - 1; - var from = this.lastRecord - 50; - if (from < 0) - from = 0; - this.loadItems(from, to); - } else { - this.loadItems(); - } - }, - loadItems: function(from, to) { } + if (this.lastRecord != null) { + var to = this.lastRecord - 1; + var from = this.lastRecord - 50; + if (from < 0) + from = 0; + this.loadItems(from, to); + } else { + this.loadItems(); + } + }, + loadItems: function(from, to) { + this.startLoadAnimation(); + }, + startLoadAnimation: function() { + this.$.spinner.show(); + this.$.spinner.start(); + }, + stopLoadAnimation: function() { + this.$.spinner.hide(); + this.$.spinner.stop(); + } });