Newer
Older
/**
* Children listing
*
* @module package/quiqqer/bricks/bin/Controls/Children/Infinite
* @author www.pcsg.de (Henning Leutz)
*
* @require qui/QUI
* @require qui/controls/Control
*/
define('package/quiqqer/bricks/bin/Controls/Children/Infinite', [
'qui/QUI',
"use strict";
return new Class({
Extends: QUIControl,
Type : 'package/quiqqer/bricks/bin/Controls/Pagination',
Binds: [
'$onImport',
initialize: function (options) {
this.parent(options);
this.addEvents({
onImport: this.$onImport
});
},
/**
* event : on import
*/
$onImport: function () {
this.$More = Elm.getElement('.button');
this.$More.removeClass('disabled');
this.$MoreFX = moofx(this.$More);
},
/**
* Show next row
*
* @return {Promise}
*/
next: function () {
return new Promise(function (resolve) {
var self = this,
size = this.$More.getSize();
this.$MoreFX.animate({
color: 'transparent'
}, {
duration: 250,
callback: function () {
self.$More.setStyles({
height : size.y,
overflow: 'hidden',
width : size.x
});
var oldButtonText = self.$More.get('text');
self.$More.set('html', '<span class="fa fa-spinner fa-spin"></span>');
self.$More.setStyle('color', null);
self.$More.addClass('loading');
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
self.$getNextChildren().then(function (result) {
var Container = new Element('div', {
html: result
});
var Row = Container.getElement(
'.quiqqer-bricks-children-infinite-row'
);
Row.setStyles({
'float' : 'left',
opacity : 0,
position: 'absolute',
overflow: 'hidden'
});
Row.inject(self.$More, 'before');
var height = Row.getSize().y;
Row.setStyles({
height : 0,
position: null
});
var childrenCount = Row.getElements(
'.quiqqer-bricks-children-infinite-child'
).length;
if (childrenCount < self.getAttribute('childrenperrow')) {
self.$More.removeEvents('click');
moofx(self.$More).animate({
cursor : 'default',
opacity: 0
});
}
moofx(Row).animate({
height : height,
opacity: 1
}, {
duration: 250,
equation: 'cubic-bezier(.17,.67,.25,1.25)',
callback: function () {
self.$More.set({
html : oldButtonText,
styles: {
self.$More.removeClass('disabled');
self.$More.removeClass('loading');
new Fx.Scroll(window.document).start(
0,
Row.getPosition().y - 200
).chain(function () {
self.$More.focus();
resolve();
});
}
});
});
}
});
}.bind(this));
},
/**
* Return the next children
*
* @return {Promise}
*/
$getNextChildren: function () {
return new Promise(function (resolve) {
var Rows = this.getElm().getElements(
'.quiqqer-bricks-children-infinite-row'
);
Ajax.get('package_quiqqer_bricks_ajax_brick_infinite_row', resolve, {
'package': 'quiqqer/bricks',
brickId : this.getElm().get('data-brickid'),
brickUID : this.getElm().get('data-brickuid'),
row : Rows.length