define('application/widgets/movies/grid', [
'application/widgets/grid',
'antie/runtimecontext',
'application/formatters/vodasset'
], function (
Grid,
RuntimeContext,
MovieItemFormatter
) {
'use strict';
var application = RuntimeContext.getCurrentApplication(),
layout = application.getLayout();
return Grid.extend({
init: function init (opts) {
this._loadmoreIndex = 3;
this._loadmoreCallback = opts.loadmoreCallback;
this._reachedEnd = false;
init.base.call(this, 'filtered-result-grid', {
grid: {
columns: 8,
height: layout.movies.grid.height,
alignPoint: 0.2,
culling: true,
continuousListener: true,
navigateNext: true,
animOptions: {
skipAnim: true
}
},
asset: {
width: layout.watchall.assetWidth,
height: layout.watchall.assetHeight,
formatter: MovieItemFormatter
}
});
},
/**
* Check if we need to load more rows.
*/
checkLoadMore: function () {
var list = this.getList(),
activeRowIndex = list.getActiveChildWidgetIndex() + 1,
rowsCount = list.getChildWidgetCount();
if (!this._reachedEnd && rowsCount && (activeRowIndex >= rowsCount - 2)) {
this._loadmoreCallback();
}
},
/**
* Reset the loadmore index.
*
* @param {boolean} value - Is reached.
*/
setReachedEnd: function (value) {
this._reachedEnd = value;
}
});
});