/www/jssrc/blerg/Pager.js
enyo.kind({
    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) {
        this.startLoadAnimation();
    },
    startLoadAnimation: function() {
        this.$.spinner.show();
        this.$.spinner.start();
    },
    stopLoadAnimation: function() {
        this.$.spinner.hide();
        this.$.spinner.stop();
    }
});